I have tried looking at other similar questions but nothing seems to get rid of the error i get.
NullReferenceException: Object reference not set to an instance of an object
I dont know if i have missed something obvious this is my first time using singletons thanks for any help.
The singleton Script
public class ManagerScript : MonoBehaviour {
public static ManagerScript Instance { get; private set; }
public int cameraOverview = 0;
private void Awake() {
if (Instance == null) {
Instance = this;
DontDestroyOnLoad(gameObject);
}
else {
Destroy(gameObject);
}
}
}
Using the singleton
void OnMouseDown() {
if (ManagerScript.Instance.cameraOverview == 1) {
Debug.Log("clicked");
}
}