Legacy Documentation: Version 5.0
Language: English
  • C#
  • JS

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

GUIContent.GUIContent

Switch to Manual
public GUIContent()

Description

Constructor for GUIContent in all shapes and sizes.

Build an empty GUIContent.


public GUIContent(text: string)

Parameters

Description

Build a GUIContent object containing only text.

When using the GUI, you don't need to create GUIContents for simple text strings - these two lines of code are functionally equivalent:

	function OnGUI () {
		GUI.Button (Rect (0, 0, 100, 20), "Click Me");
		GUI.Button (Rect (0, 30, 100, 20), GUIContent ("Click Me"));
	}

public GUIContent(image: Texture)

Parameters

Description

Build a GUIContent object containing only an image.

	var icon : Texture;

function OnGUI () { GUI.Button (Rect (0, 0, 100, 20), GUIContent (icon)); }

public GUIContent(text: string, image: Texture)

Parameters

Description

Build a GUIContent object containing both text and an image.

	var icon : Texture;

function OnGUI () { GUI.Button (Rect (0,0,100,20), GUIContent ("Click me", icon)); }

public GUIContent(text: string, tooltip: string)

Parameters

Description

Build a GUIContent containing some text. When the user hovers the mouse over it, the global GUI.tooltip is set to the tooltip.

	function OnGUI () {
		GUI.Button (Rect (0, 0, 100, 20), GUIContent ("Click me", "This is the tooltip"));
		
		// If the user hovers the mouse over the button, the global tooltip gets set
		GUI.Label (Rect (0, 40, 100, 40), GUI.tooltip);
	}

public GUIContent(image: Texture, tooltip: string)

Parameters

Description

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(text: string, image: Texture, tooltip: string)

Parameters

Description

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(src: GUIContent)

Parameters

Description

Build a GUIContent as a copy of another GUIContent.