GUIContent.GUIContentstatic function GUIContent () : GUIContentDescriptionConstructor for GUIContent in all shapes and sizes Build an empty GUIContent. static function GUIContent (text : String) : GUIContentDescriptionBuild 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:
JavaScripts
function OnGUI () {
GUI.Button (Rect (0, 0, 100, 20), "Click Me"); GUI.Button (Rect (0, 30, 100, 20), GUIContent ("Click Me")); } using UnityEngine;
using System.Collections; public class example : 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")); } } import UnityEngine
import System.Collections class example(MonoBehaviour): def OnGUI(): GUI.Button(Rect(0, 0, 100, 20), 'Click Me') GUI.Button(Rect(0, 30, 100, 20), GUIContent('Click Me')) static function GUIContent (image : Texture) : GUIContentDescriptionBuild a GUIContent object containing only an image.
JavaScripts
using UnityEngine;
using System.Collections; public class example : MonoBehaviour { public Texture icon; void OnGUI() { GUI.Button(new Rect(0, 0, 100, 20), new GUIContent(icon)); } } import UnityEngine
import System.Collections class example(MonoBehaviour): public icon as Texture def OnGUI(): GUI.Button(Rect(0, 0, 100, 20), GUIContent(icon)) static function GUIContent (text : String, image : Texture) : GUIContentDescriptionBuild a GUIContent object containing both text and an image.
JavaScripts
var icon : Texture;
function OnGUI () { GUI.Button (Rect (0,0,100,20), GUIContent ("Click me", icon)); } using UnityEngine;
using System.Collections; public class example : MonoBehaviour { public Texture icon; void OnGUI() { GUI.Button(new Rect(0, 0, 100, 20), new GUIContent("Click me", icon)); } } import UnityEngine
import System.Collections class example(MonoBehaviour): public icon as Texture def OnGUI(): GUI.Button(Rect(0, 0, 100, 20), GUIContent('Click me', icon)) static function GUIContent (text : String, tooltip : String) : GUIContentDescriptionBuild a GUIContent containing some text. When the user hovers the mouse over it, the global GUI.tooltip is set to the tooltip.
JavaScripts
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); } using UnityEngine;
using System.Collections; public class example : MonoBehaviour { void OnGUI() { GUI.Button(new Rect(0, 0, 100, 20), new GUIContent("Click me", "This is the tooltip")); GUI.Label(new Rect(0, 40, 100, 40), GUI.tooltip); } } import UnityEngine
import System.Collections class example(MonoBehaviour): def OnGUI(): GUI.Button(Rect(0, 0, 100, 20), GUIContent('Click me', 'This is the tooltip')) GUI.Label(Rect(0, 40, 100, 40), GUI.tooltip) static function GUIContent (image : Texture, tooltip : String) : GUIContentDescriptionBuild a GUIContent containing an image. When the user hovers the mouse over it, the global GUI.tooltip is set to the tooltip. static function GUIContent (text : String, image : Texture, tooltip : String) : GUIContentDescriptionBuild 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. static function GUIContent (src : GUIContent) : GUIContentDescriptionBuild a GUIContent as a copy of another GUIContent. |
