Skip to content

Instantly share code, notes, and snippets.

@MattOstgard
MattOstgard / UnityCallbackCheatSheetMonoBehaviour.cs
Last active August 31, 2023 10:19
Helper for determining what order the Unity Editor makes callbacks.
// ==== UnityCallbackCheatSheetMonoBehaviour.cs ====
//
// Use this to determine what order the editor makes callbacks.
//
// Extra useful note: Use `UnityEditor.SessionState.SetString` and the other type variants to save a value for only the
// current editor session. The value will be erased after exiting.
//
// Below is the order I found during execution in the editor. Process was I would open the editor, enter play mode,
// then exit play mode.
//
@MattOstgard
MattOstgard / maya_toggle_up_axis.py
Created August 31, 2020 14:20
Python script to toggle Maya's up axis preferences between Y and Z. Paste in the python tab of the script editor and do File > Save Save Script To Shelf.
import maya.api.OpenMaya as om
if om.MGlobal.isZAxisUp():
om.MGlobal.setYAxisUp()
else:
om.MGlobal.setZAxisUp()
import bpy, os
# I run this script whenever I install a new version of blender so I can use new official key bindings
# but still use mouse side buttons for paning, rotating and zooming.
wm = bpy.context.window_manager
kc = wm.keyconfigs.user
km = kc.keymaps['View2D']
kmi = km.keymap_items.new('view2d.zoom', 'BUTTON4MOUSE', 'PRESS')
@MattOstgard
MattOstgard / orient_to_movement_direction_-_rotation_script_controller.ms
Last active March 6, 2019 21:15
Orient to Movement Direction - Rotation Script Controller (3ds max, MaxScript)
-- Orient to Movement Direction - Rotation Script Controller
-- What it does:
-- - Orients a target object to a source object's movement direction and blends rotation between the source object's rotation and its
-- movement direction.
-- To use:
-- - Create the source object that you will animate position and rotation.
-- - Add some keyframes of the source object moving in different directions.
-- - Create the target object that will be controlled by the script.
@MattOstgard
MattOstgard / .gitattributes
Last active August 8, 2021 15:06 — forked from heiths/.gitattributes
.gitattributes for Unity3D with git-lfs
# Unity
*.cginc text
*.cs diff=csharp text
*.shader text
# Unity YAML
*.anim merge=unityyamlmerge eol=lf
*.asset merge=unityyamlmerge eol=lf
*.controller merge=unityyamlmerge eol=lf
@MattOstgard
MattOstgard / createMaxScriptApiFile.ms
Last active November 15, 2021 05:54
Create MaxScript .api file for use with the automcomplete feature of the MaxScript editor.
/***
Create MaxScript .api file for use with the automcomplete feature of the MaxScript editor.
Originally Created by:
James Haywood
http://apps.jhaywood.com/blog/
Updated by Matt Ostgard
***/
(
@MattOstgard
MattOstgard / pixi-spine_issue_68_workaround.py
Created December 14, 2015 22:53
This script works around pixi-spine issue 68 by multiplying all additive slots rgb values by alpha.
#!/usr/bin/python3
import os
import json
import math
from collections import OrderedDict
def multiply_rgb_by_alpha_and_set_alpha_to_1(hex_color):
# Turn hex to float values
rgba = []