Hello, I am making game (obviously) and I keep getting the NullReferenceException: Object reference not set to an instance of an object error for my void Start function.
My code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class UI : MonoBehaviour
{
//Public variables
public Canvas pauseMenu;
public Canvas settings;
public GameControls gameControls;
//Setup
void Start()
{
gameControls.Player.Pause.performed += _ => Pause();
}
public void Quit()
{
Application.Quit();
}
public void openSettings()
{
settings.enabled = true;
}
public void Resume()
{
Time.timeScale = 1f;
pauseMenu.enabled = true;
}
public void Pause()
{
Time.timeScale = 0f;
pauseMenu.enabled = true;
}
//controls.
}
Full error:
NullReferenceException: Object reference not set to an instance of an object
UI.Start () (at Assets/UI.cs:16)