GUIContent
Constructor for GUIContent in all shapes and sizes.
Read time 2 minutesLast updated 6 days ago
Definition
- Type: Constructor
- Namespace: UnityEngine
- Assembly: UnityEngine.IMGUIModule
GUIContent()
Constructor for GUIContent in all shapes and sizes.
public GUIContent()
Remarks
Build an empty GUIContent.
GUIContent(string)
Build a GUIContent object containing only text.
public GUIContent(string text)
Parameters
Remarks
When using the GUI, you don't need to create GUIContents for simple text strings - these two lines of code are functionally equivalent:
Examples
using UnityEngine;public class ExampleScript : MonoBehaviour{ void OnGUI() { GUI.Button(new Rect(0, 0, 100, 20), "Click Me"); GUI.Button(new Rect(0, 30, 100, 20), new GUIContent("Click Me")); }}
GUIContent(Texture)
Build a GUIContent object containing only an image.
public GUIContent(Texture image)
Parameters
Examples
using UnityEngine;public class ExampleScript : MonoBehaviour{ public Texture icon; void OnGUI() { GUI.Button(new Rect(0, 30, 100, 20), new GUIContent(icon)); }}
GUIContent(string, Texture)
Build a GUIContent object containing both text and an image.
public GUIContent(string text, Texture image)
Parameters
Examples
using UnityEngine;public class ExampleScript : MonoBehaviour{ public Texture icon; void OnGUI() { GUI.Button(new Rect(0, 30, 100, 20), new GUIContent("Click me", icon)); }}
GUIContent(string, string)
Build a GUIContent containing some text. When the user hovers the mouse over it, the global GUI.tooltip is set to the tooltip.
public GUIContent(string text, string tooltip)
Parameters
Examples
using UnityEngine;public class ExampleScript : MonoBehaviour{ void OnGUI() { GUI.Button(new Rect(0, 0, 100, 20), new GUIContent("Click me", "This is the tooltip")); // If the user hovers the mouse over the button, the global tooltip gets set GUI.Label(new Rect(0, 40, 100, 40), GUI.tooltip); }}
GUIContent(Texture, string)
Build a GUIContent containing an image. When the user hovers the mouse over it, the global GUI.tooltip is set to the tooltip.
public GUIContent(Texture image, string tooltip)
Parameters
GUIContent(string, Texture, string)
Build a GUIContent that contains both text, an image and has a tooltip defined. When the user hovers the mouse over it, the global GUI.tooltip is set to the tooltip.
public GUIContent(string text, Texture image, string tooltip)
Parameters
GUIContent(GUIContent)
Build a GUIContent as a copy of another GUIContent.
public GUIContent(GUIContent src)