using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;
public class StartupScript : MonoBehaviour
{
public TextMeshProUGUI startupText;
public bool gameHasStarted = false;
void Update()
{
if(Input.GetKey(KeyCode.Space))
{
gameHasStarted = true;
}
if(gameHasStarted)
{
startupText.enabled = false;
}
}
}
I have this script in a scripts folder and, as a component of a canvas. When I open the inspector for this script in the scripts folder, it doesn't have the public bool checkbox for gameHasStated, and it won't allow me to set a TMPro instance to startupText. Neither of these problems occur when I open the inspector for the same script in the canvas.
When I run the game, and press space, it comes back with the error
NullReferenceException: Object reference not set to an instance of an object StartupScript.Update () (at Assets/Scripts/StartupScript.cs:21)
How do I fix this?
