Create a drop down with enum and display certain variables depending on selection

Hey, so I’m trying to create a custom editor scripts which allows me to pick one of 3 options from a enum and then depending on what you picked in the inspector different variable will appear.

Here is script 1:

    public class Tool_Timer : MonoBehaviour {
    
    	public float time;
    
    	public enum TimerType{ChangeScene, option2, option3}
    	public TimerType type;
    	
    }

Here is script 2:

using UnityEngine;
using System.Collections;
using UnityEditor;

[CustomEditor(typeof(Tool_Timer))]
public class Tool_TimerEditor : Editor {

	public override void OnInspectorGUI(){
		Tool_Timer myTarget = (Tool_Timer)target;

		EditorGUILayout.EnumPopup (myTarget.type);
	}

}

Now this half works as in the inspector I can see the drop down menu and I can see all the options when clicked but who I try to change it to something else it doesn’t do anything. It’s always stuck on the “ChangeSCene”.

Any suggestions?

You need to catch and set the return value, e.g.:

myTarget.type = EditorGUILayout.EnumPopup (myTarget.type);