using UnityEngine; using System.Collections; public class Example : MonoBehaviour { void OnGUI() { GUILayout.Button("Click me!", GUILayout.MaxHeight(50)); } }
using UnityEngine; using System.Collections; public class Example : MonoBehaviour { void OnGUI() { GUILayout.Label("This label has a maximum height of 20 pixels.", GUILayout.MaxHeight(20)); } }This code creates a label with a maximum height of 20 pixels. If the content of the label takes up less space than this, the label will be smaller. If the content of the label is larger than this, the label will be truncated. Package library: Unity. Overall, GUILayout MaxHeight is a useful property in C# for controlling the size of GUI controls. It is included in the Unity package library.