Created
October 12, 2011 10:32
-
-
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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
///////////////////////////////////////////////////////////////// | |
// 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