using UnityEngine; using System.Collections; public class MyGUI : MonoBehaviour { void OnGUI() { GUILayout.BeginArea(new Rect(10, 10, 300, 200)); GUILayout.Label("Hello World!"); GUILayout.Button("Click Me!"); GUILayout.EndArea(); } }
using UnityEngine; using System.Collections; public class MyGUI : MonoBehaviour { void OnGUI() { GUILayout.BeginArea(new Rect(10, 10, Screen.width - 20, Screen.height - 20)); GUILayout.BeginVertical(); GUILayout.Label("Vertical Layout"); GUILayout.Button("Button 1"); GUILayout.Button("Button 2"); GUILayout.EndVertical(); GUILayout.EndArea(); } }In this example, a new GUI area is created that spans the entire screen except for a 10-pixel border around the edges. Within the area, a vertical layout is used to display a label and two clickable buttons labeled "Button 1" and "Button 2". These examples are part of the Unity library and do not require the use of any additional package or library.