// Use this for initialization void Start() { if (instance == null) { instance = this; DontDestroyOnLoad(this); } else { Destroy(gameObject); } score += 10; // Time.deltaTime =6767; //This line won't compile, because deltaTime is read-only }
// Use this for initialization void Start() { //if this is the first intance of the singleton //instance will not be set yet if (instance == null) { //set instance to this instance of Wk3GameManager instance = this; //Dont destroy this gameObject when you go to a new scene DontDestroyOnLoad(this); } else //otherwise, if we already have a singleton //Destroy the new one, since there can only be one { Destroy(gameObject); } //add 10 to score, look, it gets printed in the console! Score += 10; // Time.deltaTime =6767; //This line won't compile, because deltaTime is read-only }