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); } } public string Name { get; } public bool Enabled { set; get; } = true; 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); } public Label(Rect box, string initialText = null, string name = null) : this(initialText, name) { this.Box = box; automaticLayout = false; } } }