I'm completly new to unity, so I'm following a tutorial on youtube. I tried to make a "clear"
button on unity for a Notepad App for Android. But when I clicked it, it gave me an error on the console:
NullReferenceException: Object reference not set to an instance of an object
ButtonControl.ClearText () (at Assets/Scripts/ButtonControl.cs:12)
This is the Script I used:
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 = "";
}
}
Note: the tutorial I'm following is this: NOTEPAD | HOW TO MAKE AN APP IN UNITY TUTORIAL #3 - C# CODING | TEXTURES https://www.youtube.com/watch?v=7LEeKMgmFsg&list=PLZ1b66Z1KFKjbczUeqC4KYpn6fzYjLKoV&index=3 by Jimmy Vegas