I am pretty new to unity
I am trying to change the value of text object in the canvas on update to do this I attached a script called textEdit to my text object but it attached itself to the main camera also and throws and nullRefrenceExpection error pointing at the camera what am I doing wrong here.
my textEdit Script looks like this
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class textEdit : MonoBehaviour {
public static int score;
Text text;
void awake()
{
text = GetComponent<Text>();
score = 0;
}
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
text = GetComponent<Text>();
text.text = "test";
}
}