GUIContent
Constructor for GUIContent in all shapes and sizes.
Read time 2 minutesLast updated 5 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 and an image.
textpublic 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 . When the user hovers the mouse over it, the global GUI.tooltip is set to the .
texttooltippublic 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 .
tooltippublic GUIContent(Texture image, string tooltip)
Parameters
GUIContent(string, Texture, string)
Build a GUIContent that contains both , an and has a defined. When the user hovers the mouse over it, the global GUI.tooltip is set to the .
textimagetooltiptooltippublic GUIContent(string text, Texture image, string tooltip)
Parameters
GUIContent(GUIContent)
Build a GUIContent as a copy of another GUIContent.
public GUIContent(GUIContent src)