Search Unity

Unity Inspector Custom Editor GUILayout broken

Discussion in 'Editor & General Support' started by BayernMaik, Nov 7, 2020.

  1. BayernMaik

    BayernMaik

    Joined:
    Oct 15, 2019
    Posts:
    20
    Hi,
    trying to create a Toolbar centered within the editor window, but cant get it work...
    Its supposed to look like Unitys Terrain Editor Toolbar
    Unbenannt.PNG
    but it looks like this
    WTFUnity.PNG

    Code:
    Code (CSharp):
    1.        public override void OnInspectorGUI()
    2.         {
    3.             if (!EditorGUIUtility.wideMode)
    4.             {
    5.                 EditorGUIUtility.wideMode = true;
    6.                 EditorGUIUtility.labelWidth = EditorGUIUtility.currentViewWidth - 212;
    7.             }
    8.  
    9.             // Toolbar
    10.             //
    11.  
    12.             GUILayout.BeginVertical(GUILayout.Height(100));
    13.  
    14.             GUILayout.BeginArea(new Rect(0.25f * Screen.width, 0.01f * Screen.height, 0.5f * Screen.width, 0.02f * Screen.height));
    15.             toolbarSelected = GUILayout.Toolbar(toolbarSelected, toolBarContent, GUILayout.Width(0.5f * Screen.width), GUILayout.Height(0.02f * Screen.height));
    16.             GUILayout.EndArea();
    17.  
    18.             GUILayout.EndVertical();
    19.         }
    What do i need to do to make GUILayout.BeginArea(new Rect()) shown inside the editor window and not somewhere else?
     
    hsyds likes this.