Search Unity

Unity Editor box content

Discussion in 'Scripting' started by Censureret, Aug 12, 2021.

  1. Censureret

    Censureret

    Joined:
    Jan 3, 2017
    Posts:
    363
    i want to box in a section of my custom editor but i am not quite sure how.

    How can i add the following to a box:

    Code (CSharp):
    1.  
    2.         EditorGUILayout.Space();
    3.         EditorGUILayout.LabelField("Main Wind Setting", EditorStyles.boldLabel);
    4.         EditorGUI.BeginDisabledGroup(controller.SynchWindZone && controller.windZone);
    5.         WindStrength.PropertyField("Intensity", "Main Wind Strength");
    6.         WindTurbulence.PropertyField("Turbulence", "Main Wind Turbulence");
    7.         WindPulse.PropertyField("Pulse Magnitude", "Main Pulse Frequency");
    8.         EditorGUI.EndDisabledGroup();
    9.  
    10.         EditorGUILayout.Space();
    11.         WindRandomness.PropertyField("Random Offset", "Main Wind bending random offset");
    12.         EditorGUILayout.Space();
     
  2. Bunny83

    Bunny83

    Joined:
    Oct 18, 2010
    Posts:
    4,011
    Just wrap your code in a vertical group and give that group the box style

    Code (CSharp):
    1. GUILayout.BeginVertical("box");
    2. // your code
    3. GUILayout.EndVertical();
    Note: You can use pretty much any style for any visual element. For example I often use the button style for Toggles. Of course you are free to design your own styles. For more information see my IMGUI crash course and especially the section about the GUIStyle and GUISkin classes.