Question by
Fleagirl125 · Sep 20, 2017 at 09:28 PM ·
guiguitext
Instructions upon walking into BoxCollider2D
Hi! I'm really new to coding and Unity, and I'm trying to get instructions to pop up when I walk into an area and then disappear when I walk out.
I created an empty object, added a box collider to it and this script:
public GUIText referencetotext;
// Use this for initialization
void Start () {
}
void OnTriggerEnter(BoxCollider2D hit)
{
referencetotext.text = "Press the left or right arrow keys to move.";
}
void OnTriggerExit(BoxCollider2D hit)
{
referencetotext.text = "";
}
// Update is called once per frame
void Update () {
}
I should be able to create a text UI and then add it to the "referencetextbox" right? But when I drag the text over to it the error sign pops up and it won't let me add it.
Also, the text isn't appearing when I add it to the object. It shows up on my canvas but when I move it it disappears.
Thanks!
Comment