Skip to content

Instantly share code, notes, and snippets.

@AngryAnt
Created October 12, 2011 10:32
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AngryAnt/1280864 to your computer and use it in GitHub Desktop.
Save AngryAnt/1280864 to your computer and use it in GitHub Desktop.
Example of how to make editor classes in assemblies accessible in Unity (untested pseudo code).
/////////////////////////////////////////////////////////////////
// MyProxy.cs - the C# source file in your assets
/////////////////////////////////////////////////////////////////
using UnityEngine;
using UnityEditor;
using MyAssemblyNamespace;
[CustomEditor (typeof (MyBehaviour))]
public MyProxy : Editor
{
MyInspector owner;
public MyProxy ()
{
owner = new MyInspector (this);
}
public override void OnInspectorGUI ()
{
owner.OnInspectorGUI ();
}
/* ... */
}
/////////////////////////////////////////////////////////////////
// MyInspector.cs - the actual inspector code built to assembly
/////////////////////////////////////////////////////////////////
using UnityEngine;
using UnityEditor;
public class MyInspector
{
Editor proxy;
public MyInspector (Editor proxy)
{
this.proxy = proxy;
}
public void OnInspectorGUI ()
{
GUILayout.Label ("KAN HAZ INSPECTAR?!");
GUILayout.Label (string.Format ("Target: {0}", proxy.target == null ? "none" : proxy.target.ToString ()));
}
/* ... */
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment