using UnityEngine; namespace GamecraftModdingAPI.Interface.IMGUI { /// /// A simple text label. /// This wraps Unity IMGUI's Label. /// public class Label : UIElement { private bool automaticLayout = false; /// /// String to display on the label. /// public string Text { get; set; } /// /// The rectangular area that the label can use. /// public Rect Box { get; set; } = Rect.zero; public void OnGUI() { if (automaticLayout) { GUILayout.Label(Text, Constants.Default.label); } else { GUI.Label(Box, Text, Constants.Default.label); } } /// /// The label's unique name. /// public string Name { get; } /// /// Whether to display the label. /// public bool Enabled { set; get; } = true; /// /// Initializes a new instance of the class with automatic layout. /// /// Initial string to display on the label. /// The element's name. public Label(string initialText = null, string name = null) { automaticLayout = true; Text = initialText; if (name == null) { this.Name = typeof(Label).FullName + "::" + initialText; } else { this.Name = name; } IMGUIManager.AddElement(this); } /// /// Initializes a new instance of the . /// /// Rectangular area for the label. /// Initial string to display on the label. /// The element's name. public Label(Rect box, string initialText = null, string name = null) : this(initialText, name) { this.Box = box; automaticLayout = false; } } }