Skip to content

Instantly share code, notes, and snippets.

Avatar

Michael Stevenson mstevenson

View GitHub Profile
@mstevenson
mstevenson / FindReferences.cs
Last active May 2, 2018
Find Unity objects that reference a selected asset
View FindReferences.cs
using UnityEngine;
using UnityEditor;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
public class FindReferences : EditorWindow, ISerializationCallbackReceiver
{
List<string> displayedRefs = new List<string>();
@mstevenson
mstevenson / InputEvents.cs
Created Jan 6, 2015
Bind key presses to methods in Unity at runtime
View InputEvents.cs
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public delegate void InputKeyDelegate (KeyCode key);
public delegate void InputAxisDelegate (string name,float value);
public class InputEvents : MonoBehaviour
{
@mstevenson
mstevenson / SpriteAnimator.cs
Created Nov 20, 2014
2D sprite animator for Unity
View SpriteAnimator.cs
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
[RequireComponent (typeof(SpriteRenderer))]
public class SpriteAnimator : MonoBehaviour
{
public List<Sprite> frames = new List<Sprite> ();
public float fps = 15;
View GameWindowMover.cs
using UnityEngine;
using UnityEditor;
//Version 0.21 | twitter:@izm update for DK2
//Version 0.2 | s.b.Newsom Edition
//Source from http://answers.unity3d.com/questions/179775/game-window-size-from-editor-window-in-editor-mode.html
//Modified by seieibob for use at the Virtual Environment and Multimodal Interaction Lab at the University of Maine.
//Use however you'd like!
@mstevenson
mstevenson / ConfigurableJointExtensions.cs
Created Oct 24, 2014
Extension methods for working with Configurable Joints for Unity
View ConfigurableJointExtensions.cs
using UnityEngine;
public static class ConfigurableJointExtensions
{
/// <summary>
/// Sets a joint's targetRotation to match a given local rotation.
/// The joint transform's local rotation must be cached on Start and passed into this method.
/// </summary>
public static void SetTargetRotationLocal (this ConfigurableJoint joint, Quaternion targetLocalRotation, Quaternion startLocalRotation)
{
@mstevenson
mstevenson / gist:0e3b03cefe82c7ff2e6e
Created Sep 27, 2014
All ffmpeg optional codecs through homebrew
View gist:0e3b03cefe82c7ff2e6e
brew install ffmpeg --with-vpx --with-libvpx --with-vorbis --with-libvorbis --with-theora --with-libtheora --with-libogg --with-gpl --with-version3 --with-nonfree --with-postproc --with-libaacplus --with-libass --with-libcelt --with-libfaac --with-libfdk-aac --with-libfreetype --with-libmp3lame --with-libopencore-amrnb --with-libopencore-amrwb --with-libopenjpeg --with-openssl --with-libopus --with-libschroedinger --with-libspeex --with-libvo-aacenc --with-libx264 --with-libxvid
@mstevenson
mstevenson / maya_sublime.mel
Last active Aug 29, 2015 — forked from fredrikaverpil/maya_sublime.py
Send selected code snippets to Maya via commandPort
View maya_sublime.mel
// Close ports if they were already open under another configuration
if (catch(`commandPort -name ":7001" -close True`)) {
warning "Could not close port 7001 (maybe it is not opened yet...)";
}
if (catch(`commandPort -name ":7002" -close True`)) {
warning "Could not close port 7002 (maybe it is not opened yet...)";
}
// Open new ports
commandPort -name ":7001" -sourceType "mel";
View CreateMergedMesh.cs
using UnityEngine;
using UnityEditor;
using System.Collections;
using System.Collections.Generic;
public class CreateMergedMesh : ScriptableWizard
{
[MenuItem ("Prototype/Create Merged Mesh")]
static void CreateDataMesh ()
{
View ObliqueCameraProjection.cs
using UnityEngine;
using System.Collections;
public class ObliqueCameraProjection : MonoBehaviour
{
private Matrix4x4 originalProjection;
public Vector2 slideViewport;
public Vector2 slideFrustum;
public Vector2 slideFarClip; // compound slideViewport and slideFrustum
public Vector2 skew;
@mstevenson
mstevenson / gist:10706756
Created Apr 15, 2014
GetComponentsInChildrenRecursive
View gist:10706756
void GetComponentsInChildrenRecursive<T> (Transform parent, List<T> buffer)
where T : Component
{
foreach (Transform t in parent) {
var c = t.GetComponent<T> ();
if (c) {
buffer.Add (c);
}
GetComponentsInChildrenRecursive (t, buffer);
}