Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

GUILayout.BeginArea() hides gizmos from the scene

Discussion in 'Immediate Mode GUI (IMGUI)' started by FeastSC2, Jun 20, 2017.

  1. FeastSC2

    FeastSC2

    Joined:
    Sep 30, 2016
    Posts:
    978
    Handles.BeginGUI(Rect) is deprecated, Unity says we must use GUILayout.BeginArea() instead.
    But when using GUILayout.BeginArea with Handles it makes the transform gizmos disappear
    (translate, rotate, scale, ...).

    I assume that's a bug in Unity, but in the meantime what can I do to keep the gizmos visible in my scene along with the custom buttons I create in it?

    Code (CSharp):
    1.  
    2. private void OnScene(SceneView sceneview)
    3. {
    4.  
    5. GUILayout.BeginArea(new Rect(0, 25, 150, 900));
    6.                 //Handles.BeginGUI(new Rect(0, 25, 150, 900));
    7.                 if (GUILayout.Button("Button"))
    8.                 {
    9.                    
    10.                 }
    11.                 GUILayout.EndArea();
    12.                 //Handles.EndGUI();
    13. }
    14.  
    15.  
     
  2. PsyKaw

    PsyKaw

    Joined:
    Aug 16, 2012
    Posts:
    102
    BeginGUI(Rect position) is deprecated but not BeginGUI(). You have to use it like this:

    Code (csharp):
    1.  
    2. private void OnScene(SceneView sceneview)
    3. {
    4.     Handles.BeginGUI());
    5.     GUILayout.BeginArea(new Rect(0, 25, 150, 900));
    6.     if (GUILayout.Button("Button"))
    7.     {
    8.      
    9.     }
    10.     GUILayout.EndArea();
    11.     Handles.EndGUI();
    12. }
    13.  
     
    FeastSC2 likes this.
  3. FeastSC2

    FeastSC2

    Joined:
    Sep 30, 2016
    Posts:
    978
    Thanks PsyKaw! Works like a charm!