using System.Runtime.CompilerServices; namespace BansheeEngine { /// /// Holds data used for displaying content in a GUIElement. Content can consist of a string, image, a tooltip or none /// of those. /// public sealed class GUIContent { private LocString text; private LocString tooltip; private SpriteTexture image; /// /// Returns string content (if any). /// public LocString Text { get { return text; } } /// /// Returns image content (if any). /// public SpriteTexture Image { get { return image; } } /// /// Returns tooltip content (if any). /// public LocString Tooltip { get { return tooltip; } } /// /// Constructs content with just a string. /// /// Textual portion of the content to be displayed as label in GUI elements. public GUIContent(LocString text) { this.text = text; } /// /// Constructs content with a string and a tooltip. /// /// Textual portion of the content to be displayed as label in GUI elements. /// Tooltip to be displayed when user hovers over a GUI element. public GUIContent(LocString text, LocString tooltip) { this.text = text; this.tooltip = tooltip; } /// /// Constructs content with just an image. /// /// Image to be displayed on top of the GUI element. public GUIContent(SpriteTexture image) { this.image = image; } /// /// Constructs content with an image and a tooltip. /// /// Image to be displayed on top of the GUI element. /// Tooltip to be displayed when user hovers over a GUI element. public GUIContent(SpriteTexture image, LocString tooltip) { this.image = image; this.tooltip = tooltip; } /// /// Constructs content with a string and an image. /// /// Textual portion of the content to be displayed as label in GUI elements. /// /// Image to be displayed on top of the GUI element. Image will be placed to the right or to the /// left of the text depending on active GUI style. /// public GUIContent(LocString text, SpriteTexture image) { this.text = text; this.image = image; } /// /// Constructs content with a string, an image and a tooltip. /// /// Textual portion of the content to be displayed as label in GUI elements. /// /// Image to be displayed on top of the GUI element. Image will be placed to the right or to the /// left of the text depending on active GUI style. /// /// Tooltip to be displayed when user hovers over a GUI element. /// public GUIContent(LocString text, SpriteTexture image, LocString tooltip) { this.text = text; this.image = image; this.tooltip = tooltip; } /// /// Implicitly converts a localized string into a GUI content containing only text. /// /// Localized string to initialize the GUI content with. /// GUI content containing only a string. public static implicit operator GUIContent(LocString text) { return new GUIContent(text); } /// /// Implicitly converts a string into a GUI content containing only text. /// /// String to initialize the GUI content with. /// GUI content containing only a string. public static implicit operator GUIContent(string text) { return new GUIContent(new LocString(text)); } } }