position | Rectangle on the screen to use for the label. |
text | Text to display on the label. |
image | Texture to display on the label. |
content | Text, image and tooltip for this label. |
style | The style to use. If left out, the label style from the current GUISkin is used. |
Make a text or texture label on screen.
function OnGUI () { GUI.Label (Rect (10, 10, 100, 20), "Hello World!"); }
using UnityEngine; using System.Collections; public class Example : MonoBehaviour { void OnGUI() { GUI.Label(new Rect(10, 10, 100, 20), "Hello World!"); } }
import UnityEngine import System.Collections public class Example(MonoBehaviour): def OnGUI() as void: GUI.Label(Rect(10, 10, 100, 20), 'Hello World!')
var textureToDisplay : Texture2D; function OnGUI () { GUI.Label (Rect (10, 40, textureToDisplay.width, textureToDisplay.height), textureToDisplay); }
using UnityEngine; using System.Collections; public class Example : MonoBehaviour { public Texture2D textureToDisplay; void OnGUI() { GUI.Label(new Rect(10, 40, textureToDisplay.width, textureToDisplay.height), textureToDisplay); } }
import UnityEngine import System.Collections public class Example(MonoBehaviour): public textureToDisplay as Texture2D def OnGUI() as void: GUI.Label(Rect(10, 40, textureToDisplay.width, textureToDisplay.height), textureToDisplay)