Box
Make an auto-layout box.
Read time 7 minutesLast updated 7 days ago
Definition
- Type: Method
- Namespace: UnityEngine
- Assembly: UnityEngine.IMGUIModule
Box(Texture, GUILayoutOption[])
Make an auto-layout box.
public static void Box(Texture image, params GUILayoutOption[] options)
Parameters
An optional list of layout options that specify extra layouting properties. Any values passed in here will override settings defined by the style.
Additional Resources: GUILayout.Width, GUILayout.Height, GUILayout.MinWidth, GUILayout.MaxWidth, GUILayout.MinHeight, GUILayout.MaxHeight, GUILayout.ExpandWidth, GUILayout.ExpandHeight.
Additional Resources: GUILayout.Width, GUILayout.Height, GUILayout.MinWidth, GUILayout.MaxWidth, GUILayout.MinHeight, GUILayout.MaxHeight, GUILayout.ExpandWidth, GUILayout.ExpandHeight.
Remarks
This will make a box that contains static text or images but not other GUI controls. If you want to make a rectangular container for a set of GUI controls, use one of the grouping functions (GUILayout.BeginHorizontal, GUILayout.BeginVertical, GUILayout.BeginArea, etc...).

Boxes in the Game View.
Examples
using UnityEngine;public class ExampleScript : MonoBehaviour{ Texture tex; void OnGUI() { if (!tex) { Debug.LogError("Missing texture, assign a texture in the inspector"); } GUILayout.Box(tex); GUILayout.Box("This is a sized label"); }}
Box(string, GUILayoutOption[])
Make an auto-layout box.
public static void Box(string text, params GUILayoutOption[] options)
Parameters
Text to display on the box.
An optional list of layout options that specify extra layouting properties. Any values passed in here will override settings defined by the style.
Additional Resources: GUILayout.Width, GUILayout.Height, GUILayout.MinWidth, GUILayout.MaxWidth, GUILayout.MinHeight, GUILayout.MaxHeight, GUILayout.ExpandWidth, GUILayout.ExpandHeight.
Additional Resources: GUILayout.Width, GUILayout.Height, GUILayout.MinWidth, GUILayout.MaxWidth, GUILayout.MinHeight, GUILayout.MaxHeight, GUILayout.ExpandWidth, GUILayout.ExpandHeight.
Remarks
This will make a box that contains static text or images but not other GUI controls. If you want to make a rectangular container for a set of GUI controls, use one of the grouping functions (GUILayout.BeginHorizontal, GUILayout.BeginVertical, GUILayout.BeginArea, etc...).

Boxes in the Game View.
Examples
using UnityEngine;public class ExampleScript : MonoBehaviour{ Texture tex; void OnGUI() { if (!tex) { Debug.LogError("Missing texture, assign a texture in the inspector"); } GUILayout.Box(tex); GUILayout.Box("This is a sized label"); }}
Box(GUIContent, GUILayoutOption[])
Make an auto-layout box.
public static void Box(GUIContent content, params GUILayoutOption[] options)
Parameters
Text, image and tooltip for this box.
An optional list of layout options that specify extra layouting properties. Any values passed in here will override settings defined by the style.
Additional Resources: GUILayout.Width, GUILayout.Height, GUILayout.MinWidth, GUILayout.MaxWidth, GUILayout.MinHeight, GUILayout.MaxHeight, GUILayout.ExpandWidth, GUILayout.ExpandHeight.
Additional Resources: GUILayout.Width, GUILayout.Height, GUILayout.MinWidth, GUILayout.MaxWidth, GUILayout.MinHeight, GUILayout.MaxHeight, GUILayout.ExpandWidth, GUILayout.ExpandHeight.
Remarks
This will make a box that contains static text or images but not other GUI controls. If you want to make a rectangular container for a set of GUI controls, use one of the grouping functions (GUILayout.BeginHorizontal, GUILayout.BeginVertical, GUILayout.BeginArea, etc...).

Boxes in the Game View.
Examples
using UnityEngine;public class ExampleScript : MonoBehaviour{ Texture tex; void OnGUI() { if (!tex) { Debug.LogError("Missing texture, assign a texture in the inspector"); } GUILayout.Box(tex); GUILayout.Box("This is a sized label"); }}
Box(Texture, GUIStyle, GUILayoutOption[])
Make an auto-layout box.
public static void Box(Texture image, GUIStyle style, params GUILayoutOption[] options)
Parameters
An optional list of layout options that specify extra layouting properties. Any values passed in here will override settings defined by the style.
Additional Resources: GUILayout.Width, GUILayout.Height, GUILayout.MinWidth, GUILayout.MaxWidth, GUILayout.MinHeight, GUILayout.MaxHeight, GUILayout.ExpandWidth, GUILayout.ExpandHeight.
Additional Resources: GUILayout.Width, GUILayout.Height, GUILayout.MinWidth, GUILayout.MaxWidth, GUILayout.MinHeight, GUILayout.MaxHeight, GUILayout.ExpandWidth, GUILayout.ExpandHeight.
Remarks
This will make a box that contains static text or images but not other GUI controls. If you want to make a rectangular container for a set of GUI controls, use one of the grouping functions (GUILayout.BeginHorizontal, GUILayout.BeginVertical, GUILayout.BeginArea, etc...).

Boxes in the Game View.
Examples
using UnityEngine;public class ExampleScript : MonoBehaviour{ Texture tex; void OnGUI() { if (!tex) { Debug.LogError("Missing texture, assign a texture in the inspector"); } GUILayout.Box(tex); GUILayout.Box("This is a sized label"); }}
Box(string, GUIStyle, GUILayoutOption[])
Make an auto-layout box.
public static void Box(string text, GUIStyle style, params GUILayoutOption[] options)
Parameters
Text to display on the box.
An optional list of layout options that specify extra layouting properties. Any values passed in here will override settings defined by the style.
Additional Resources: GUILayout.Width, GUILayout.Height, GUILayout.MinWidth, GUILayout.MaxWidth, GUILayout.MinHeight, GUILayout.MaxHeight, GUILayout.ExpandWidth, GUILayout.ExpandHeight.
Additional Resources: GUILayout.Width, GUILayout.Height, GUILayout.MinWidth, GUILayout.MaxWidth, GUILayout.MinHeight, GUILayout.MaxHeight, GUILayout.ExpandWidth, GUILayout.ExpandHeight.
Remarks
This will make a box that contains static text or images but not other GUI controls. If you want to make a rectangular container for a set of GUI controls, use one of the grouping functions (GUILayout.BeginHorizontal, GUILayout.BeginVertical, GUILayout.BeginArea, etc...).

Boxes in the Game View.
Examples
using UnityEngine;public class ExampleScript : MonoBehaviour{ Texture tex; void OnGUI() { if (!tex) { Debug.LogError("Missing texture, assign a texture in the inspector"); } GUILayout.Box(tex); GUILayout.Box("This is a sized label"); }}
Box(GUIContent, GUIStyle, GUILayoutOption[])
Make an auto-layout box.
public static void Box(GUIContent content, GUIStyle style, params GUILayoutOption[] options)
Parameters
Text, image and tooltip for this box.
An optional list of layout options that specify extra layouting properties. Any values passed in here will override settings defined by the style.
Additional Resources: GUILayout.Width, GUILayout.Height, GUILayout.MinWidth, GUILayout.MaxWidth, GUILayout.MinHeight, GUILayout.MaxHeight, GUILayout.ExpandWidth, GUILayout.ExpandHeight.
Additional Resources: GUILayout.Width, GUILayout.Height, GUILayout.MinWidth, GUILayout.MaxWidth, GUILayout.MinHeight, GUILayout.MaxHeight, GUILayout.ExpandWidth, GUILayout.ExpandHeight.
Remarks
This will make a box that contains static text or images but not other GUI controls. If you want to make a rectangular container for a set of GUI controls, use one of the grouping functions (GUILayout.BeginHorizontal, GUILayout.BeginVertical, GUILayout.BeginArea, etc...).

Boxes in the Game View.
Examples
using UnityEngine;public class ExampleScript : MonoBehaviour{ Texture tex; void OnGUI() { if (!tex) { Debug.LogError("Missing texture, assign a texture in the inspector"); } GUILayout.Box(tex); GUILayout.Box("This is a sized label"); }}