【UnityEditor】根据枚举的不同显示各自对应的内容
code1--PhoneManage
public class PhoneManage:MonoBehaviour { public enum Platform { A,B } public Platform curPlatform = Platform.A; public Vector3 a1,a2; public int b1; public Vector3 c1; }
code2--IEditor(放入Editor文件夹下)
[CustomEditor(typeof(PhoneManage))] public class IEditor : Editor { public override void OnInspectorGUI() { PhoneManage me = (PhoneManage)target; me.curPlatform = (PhoneManage.Platform)EditorGUILayout.EnumPopup ("type", me.curPlatform); switch(me.curPlatform) { case PhoneManage.Platform.A: me.a1 = EditorGUILayout.Vector3Field("a1",me.a1); me.a2 = EditorGUILayout.Vector3Field("a2",me.a2); break; case PhoneManage.Platform.B: me.b1 = EditorGUILayout.IntField("b1",me.b1); break; } } }