EditorGUILayout.Popup option is not changing

4k Views Asked by At

using this simple code I'm showing a dropdown

 int selected = 0;
            ///*
            string[] options = new string[]
            {
                "Start With", "End With", "Contains", 
            };

            //criteria = EditorGUILayout.Popup("Search Criteria", 2, options);
            //*/
            criteria = EditorGUILayout.Popup("Awesome Drop down:",  selected, options, EditorStyles.popup);

it showing dropdown with option perfectly but the problem is option is not changing when I try to select another option? what is missing?

1

There are 1 best solutions below

1
On BEST ANSWER

don't use "selected" AND "criteria". you must use the same ONE variable:

        int selected = 0;
        ///*
        string[] options = new string[]
        {
            "Start With", "End With", "Contains", 
        };

        //selected = EditorGUILayout.Popup("Search Criteria", 2, options);
        //*/
        selected = EditorGUILayout.Popup("Awesome Drop down:",  selected, options, EditorStyles.popup);

because this is the way your choice is saved