Search Unity

Custom Editors and Singletons

Discussion in 'Editor & General Support' started by JamesPro, Feb 1, 2015.

  1. JamesPro

    JamesPro

    Joined:
    Mar 5, 2012
    Posts:
    509
    Ok So I'm in the process of doing some Major tool development which consists of Unity Custom Editors and lots of Singleton Classes that are created and are vital to my tools. Problem I am finding is that they get destroyed when ever you press the Play Button in the Editor. Is there any way to ensure that things stay created when you attempt to play your game in the editor?

    Here's an example of how I create my Singletons:

    private static NetworkManager instance = null;
    public static NetworkManager Instance
    {
    get {
    if (instance == null)
    instance = new NetworkManager();
    return instance;
    }
    }
     
  2. JamesPro

    JamesPro

    Joined:
    Mar 5, 2012
    Posts:
    509
    Anyone have a solution for this?
     
  3. steego

    steego

    Joined:
    Jul 15, 2010
    Posts:
    969