Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Bug EditorGUILayout.Popup not functional when using EditorWindow.ShowModalUtility

Discussion in 'Editor & General Support' started by MartinAvatar, Dec 2, 2020.

  1. MartinAvatar

    MartinAvatar

    Joined:
    Mar 12, 2018
    Posts:
    1
    Hi,

    I'm trying to make a popup in the OnGUI method of an EditorWindow and am confident I am calling the EditorGUILayout.Popup method correctly.

    When I try to show the window using EditorWindow.ShowModalUtility(), the popup options are not selectable, but when I simply use EditorWindow.Show(), or any other Show method, the popup options can be selected.

    Does Not Work:

    Code (CSharp):
    1.  
    2. public class MyModalUtility : EditorWindow{
    3.  
    4. public string[] options = new string[] {"1", "2", "3"};
    5. public int index;
    6.  
    7. public static void Init(){
    8. MyModalUtility window = ScriptableObject.CreateInstance<MyModalUtility>();
    9. window.titleContent = new GUIContent("Modal Utility");
    10. window.maxSize = new Vector2(300, 150);
    11. window.minSize = new Vector2(300, 150);
    12. window.position = new Rect(Screen.width / 4, Screen.height / 4, 250, 150);
    13. window.ShowModalUtility();
    14. }
    15.  
    16. void OnGUI(){
    17. index = EditorGUILayout.Popup(" PopupOption",index, options);
    18. }
    19. }
    20.  
    Works:

    Code (CSharp):
    1.  
    2.  
    3. public class MyModalUtility : EditorWindow{
    4.  
    5. public string[] options = new string[] {"1", "2", "3"};
    6. public int index;
    7.  
    8. public static void Init(){
    9. MyModalUtility window = ScriptableObject.CreateInstance<MyModalUtility>();
    10. window.titleContent = new GUIContent("Modal Utility");
    11. window.maxSize = new Vector2(300, 150);
    12. window.minSize = new Vector2(300, 150);
    13. window.position = new Rect(Screen.width / 4, Screen.height / 4, 250, 150);
    14. //CHANGE HERE
    15. window.Show();
    16. }
    17.  
    18. void OnGUI(){
    19. index = EditorGUILayout.Popup(" PopupOption",index, options);
    20. }
    21. }
    22.  
    I'm using 2019.4.15f1

    Is this a bug, or am I implementing the method incorrectly?

    Thanks
     
    marlene-next and weij like this.
  2. jonathan_lumos

    jonathan_lumos

    Joined:
    Jan 20, 2022
    Posts:
    1
    Same issue. 2019.4.25f1
     
  3. marlene-next

    marlene-next

    Joined:
    Oct 14, 2021
    Posts:
    1
    I think this is a bug, I have the same issue. It is a problem on MacOS but not on Windows.
     
  4. unity_E6C63A33953CBDC70701

    unity_E6C63A33953CBDC70701

    Joined:
    Jan 25, 2022
    Posts:
    1