0

With this code:

 public class StartButtonScript : MonoBehaviour {

// Use this for initialization
void Start () {

}

// Update is called once per frame
void OnMouseDown () {
    Destroy(GameObject.Find("StartButtonText"));
    Destroy(GameObject.Find("TitleText"));
    (GameObject.Find("Tutorial0")).SetActive(true);
    Debug.Log("Entered Game");
}
}

Unity says that there is a NullReferenceException error and it won't activate the 'Tutorial0' 3D text box. From the beginning, the text box is deactivated so I think that this is the problem, however I don't know anyway around it (that wouldn't take a whole bunch of time). Is there a simple fix to this?

  • `GameObject.Find` cannot find inactive Objects. You have to assign that from the Editor. Something like this: `public GameObject tutorial;` then `tutorial.SetActive(true);` – Programmer Apr 06 '17 at 04:17
  • Now I am getting an "UnassignedRefernceException. The variable Tutorial0 of StartButtonScript has not been assigned. You probably need to assign the Tutorial0 variable of the StartButtonScript script in the inspector." What do I do now? – Chukedog Apr 06 '17 at 04:30
  • You have to drag that Tutorial10 GameObject to the tutorial variable slot. – Programmer Apr 06 '17 at 04:33

0 Answers0