Hey! I would like to change text on mouse pressed. I have a canvas and text parented to it. I’ve looked at API:
and wrote a simmiliar code, but it doesn’t work. In particular, in line: instruction.text = “this is text”; .text is highlighted red. Could you please help me? Thank you!
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class countscript : MonoBehaviour {
public Text[] instruction;
// Use this for initialization
void Start () {
instruction = GetComponentsInChildren<Text> ();
}
// Update is called once per frame
void Update () {
if (Input.GetButton ("Fire1")) {
instruction.text = "this is text";
}
}
}