Skip to content

Instantly share code, notes, and snippets.

@AngryAnt

AngryAnt/MyProxy.cs

Created Oct 12, 2011
Embed
What would you like to do?
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