Last active
September 16, 2015 21:22
-
-
Save unitycoder/812f7e0729683ea889d1 to your computer and use it in GitHub Desktop.
Call function if OnGUI() dropdown item was selected
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// vars | |
string[] optionList = new string[] {"Apples", "Oranges", "Androids"}; | |
int index = 0; | |
// loop | |
void OnGUI() | |
{ | |
GUI.changed = false; // not needed if EditorGUILayout.Popup is first in OnGUI | |
index = EditorGUILayout.Popup("My List",index, optionList); | |
if (GUI.changed) DoSomething(); // NOTE: gets also called if same item is selected from list | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment