title: How can I make my instance of a Singleton MonoBehaviour class start as new when reloading the scene?
body: <p>I have a 'SingletonManager' class with an instance of the 'LevelManager' singleton (and interface to it). The 'LevelManager' GameObject is not supposed to be persistant throughout the application lifetime and should be replaced with a new instance every time a new level is loaded.</p>
  
  <p>While running my current code, when the scene is loaded for the second time, 'LevelManager' seems to be missing, despite the GameObject (with script attached) being in the scene. I realise that this is probably because I am still trying to access the old reference.</p>
  
  <p>What is the best way to ensure that my 'SingletonManager' holds the new instance of 'LevelManager' every time a new level is loaded?</p>
  
  <p>My code (with irrelevance removed):</p>
  
  <p>SingletonManager:</p>
  
  <pre><code>public class SingletonManager
  {
      private static LevelManager instance;
      public static ILevelManager Instance
      {
          get
          {
              if (this.levelManager == null)
              {
                  this.levelManager = GameObject.FindObjectOfType(typeof(LevelManager)) as LevelManager;
              }
              return this.levelManager;
          }
      }
  }
  </code></pre>
  
  <p>Singleton, is not persistant:</p>
  
  <pre><code>public class Singleton&lt;Instance&gt; : MonoBehaviour where Instance : Singleton&lt;Instance&gt; {
      public static Instance instance;
      public bool isPersistant;
  
      public virtual void Awake() {
          if(isPersistant) {
              if(!instance) {
                  instance = this as Instance;
              }
              else {
                  DestroyObject(gameObject);
              }
              DontDestroyOnLoad(gameObject);
          }
          else {
              instance = this as Instance;
          }
      }
  }
  </code></pre>