I am new to Unity and have been following this tutorial. Basically, I am trying to make a button clear a block of text if pressed. I'm pretty sure I followed all of the steps, but I am getting a NullReferenceException error when I click on the button.
What am I missing/doing wrong? Any tips on what to do if I run into this error in the future?
Here's the code that I have, which should be the exact same as in the tutorial:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class ButtonControl : MonoBehaviour
{
public GameObject theText;
public void ClearText()
{
theText.GetComponent<InputField>().text = "";
}
}
Here's the hierarchy image, the GameObject I created, and my button command.