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.

Question How to fix editor window size

Discussion in 'Immediate Mode GUI (IMGUI)' started by AzpxMsw, Jan 19, 2023.

  1. AzpxMsw

    AzpxMsw

    Joined:
    Jun 1, 2020
    Posts:
    12
    I need to fix min and max editor window size. Here's a code:

    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEditor;
    3. using System.Collections;
    4. using System.Collections.Generic;
    5.  
    6. public class SampleWindow : EditorWindow
    7. {
    8.     bool Colliders;
    9.     bool Other;
    10.  
    11.     Vector2 scrollView = Vector2.zero;
    12.  
    13.     [MenuItem("Window/Other/Open Sample Window #M")]
    14.     static void onOpen()
    15.     {
    16.         EditorWindow.GetWindow(typeof(SampleWindow));
    17.     }
    18.     //Here I need to fix min and max window size
    19.  
    20.     void OnGUI()
    21.     {
    22.         Colliders = EditorGUILayout.Foldout(Colliders, "Colliders");
    23.         if (Colliders)
    24.         {
    25.             EditorGUILayout.BeginHorizontal();
    26.             if (GUILayout.Button("Box", GUILayout.MinWidth(115), GUILayout.MaxWidth(135)))
    27.             {
    28.                 GameObject build = new GameObject("Box");
    29.                 BoxCollider collider = build.AddComponent<BoxCollider>();
    30.                 collider.isTrigger = true;
    31.                 Selection.activeGameObject = build;
    32.             }
    33.             if (GUILayout.Button("Mesh", GUILayout.MinWidth(115), GUILayout.MaxWidth(135)))
    34.             {
    35.                 GameObject build = new GameObject("Mesh");
    36.                 build.AddComponent<UnityEngine.MeshCollider>();
    37.                 Selection.activeGameObject = build;
    38.             }
    39.             EditorGUILayout.EndHorizontal();
    40.         }
    41.  
    42.         Other = EditorGUILayout.Foldout(Other, "Other");
    43.         if (Other)
    44.         {
    45.         }
    46.     }
    47. }