I have the following Editor code: Code (CSharp): using UnityEngine; using UnityEditor; using System.Collections; [CustomEditor(typeof(GameEvent))] public class EasyCommandEditor : Editor { override public void OnInspectorGUI(){ DrawDefaultInspector(); GameEvent targ = target as GameEvent; GameEvent.GameEvents newValue = (GameEvent.GameEvents)EditorGUILayout.EnumPopup(targ.gameEvent); } } Instead of drawing the enum to the Inspector, is it possible to just get the value when it changes?
Hey , check out my editor script I posted here: http://forum.unity3d.com/threads/script-editor-creator.305078/ It also uses an enum ('type') which doesn't need to be displayed anywhere but still updates everything immediately, thanks to the serialized objects.
@Juice-Tin Thanks! That I think will do what I want! I would like to do this instead of a switch: Code (CSharp): if(_evt != (GameEvent.GameEvents)evt.intValue){ } But it doesn't seem to work because the two values are always the same. Any idea of a way to accomplish this?
If you want to check for a change on a Serialized property you can use the EditorGUI.BeginChangeCheck and EditorGUI.EndChangeCheck function calls. Code (CSharp): SerializedProperty _evt = serializedObject.FindProperty("NameOfVariable"); EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(_evt); if(EditorGUI.EndChangeCheck()) { if(_evt.intValue == EnumValue) //specific code here else if(_evt.intValue == AnotherEnumValue) //code here }