Skip to content

Instantly share code, notes, and snippets.

@tinyhappysteps
Created December 13, 2015 14:21
Show Gist options
  • Save tinyhappysteps/e8ea3d3ef0a7d40cd767 to your computer and use it in GitHub Desktop.
Save tinyhappysteps/e8ea3d3ef0a7d40cd767 to your computer and use it in GitHub Desktop.
Text UI in Unity
using UnityEngine;
using System.Collections;
using UnityEngine.UI; // brings in UI information
public class TextController : MonoBehaviour {
public Text text; // requires UnityEngine.UI, publicly exposes the text
// Use this for initialization
void Start () {
text.text = "Hello World";
}
// Update is called once per frame
void Update () {
if (Input.GetKeyDown (KeyCode.Space)){
text.text = "Space key pressed";
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment