Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Bug GUILayout.Button possible bug

Discussion in 'Editor & General Support' started by erickbretoMVI, Nov 29, 2023.

  1. erickbretoMVI

    erickbretoMVI

    Joined:
    May 3, 2023
    Posts:
    4
    Using Unity 2022.3.9f1

    Apparently if you use inheritance with an editor window inherited script, GUILayout.button function gets bugged out?
    Code (CSharp):
    1. public class FooA: EditorWindow {
    2.  void OnGUI(){
    3.   if(GuiLayout.Button("DoStuff")){
    4.   Debug.Log("Clicked");
    5.   }
    6.  }
    7. }
    Code (CSharp):
    1. public class FooB: FooA{
    2.  
    3. override void OnGUI(){
    4.   base.OnGUI();
    5.  }
    6.  
    7. }
    If we make an editor window with class FooB, the GuiLayout.Button function gets called multiple times and "Clicked" gets printed to the console multiple times, even when I just hover the mouse over the window and don't click the button the function still gets called. Any ideas?
     
  2. erickbretoMVI

    erickbretoMVI

    Joined:
    May 3, 2023
    Posts:
    4
    Looks like restarting Unity fixed it after sometime.