private void Awake() { if (instance == null) { //if not, set instance to this instance = this; } //If instance already exists and it's not this: else if (instance != this) { //Then destroy this. This enforces our singleton pattern, meaning there can only ever be one instance of a GameManager. Destroy(gameObject); } }
// Use this for initialization void Start() { control = GameObject.FindGameObjectWithTag("Player").GetComponent <Control>(); a = pendulum.GetComponent <Pendulum2>(); s = GetComponent <SpriteRenderer>(); coli = GetComponent <Collider2D>(); if (PlayerPrefs.GetInt("Newgame") == 1) { PlayerPrefs.SetInt(gameObject.name, 0); } if (PlayerPrefs.GetInt(gameObject.name) == 1) { Disable(); } }