- Home /
Popup options not changing in custom editor script
I have a custom editor window that aids in the creation of dialogue. The lines are all stored in a List of dialogue objects. No GameObject or any other object inside the scene is being altered, the window simply streamlines the dialogue file creation.
The problem is, the Popups don't change. I can view the dropdown options, but when I click, the option doesn't change. Here's the code that I'm using to generate the options in the OnGUI()
method:
int[] charselects = new int[scene.dialogues.Count];
int[] poseselects = new int[scene.dialogues.Count];
Array.Clear(charselects, 0, charselects.Length);
Array.Clear(poseselects, 0, poseselects.Length);
foreach (Dialogue dia in scene.dialogues)
{
int charselected = charselects[scene.dialogues.IndexOf(dia)];
int poseselected = poseselects[scene.dialogues.IndexOf(dia)];
EditorGUILayout.BeginHorizontal();
charselected = EditorGUILayout.Popup("Character", charselected, Characters.All);
dia.character = Characters.All[charselected];
poseselected = EditorGUILayout.Popup("Pose", poseselected, Poses.All);
dia.pose = Poses.All[poseselected];
dia.pos = (Position)EditorGUILayout.EnumPopup("Position", Position.Left);
Debug.Log(dia.pos);
Debug.Log(dia.character);
dia.text = EditorGUILayout.TextField("Text");
EditorGUILayout.EndHorizontal();
}
I made the charselects
and poseselects
array because I read here that the Popup requires the same selected value. Originally, I was assigning selected
each time in the loop without the array. Neither of these work. Anyone know how to fix this?
Your answer
Follow this Question
Related Questions
serializedObject with EditorGUILayout.Popup in C# 1 Answer
Event.button activating constantly? 0 Answers
Editor GUI in Built Game 1 Answer
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers