Instantiate or get Instance of Singleton from another Singleton?

I define my Proxy or Model Classes as Singletons.
I’ve created a base singleton which child classes then inherit.
Normally you simply get a reference to a Singleton

mySingletonInstance = Singleton.Instance;

But what if you have one Singleton that needs a reference to another Singleton?
Would you do it the same way?

public class GenericProxy<T> : MonoBehaviour where T : Component
{
  private static T instance;
  public static T Instance
  {
  get
  {
  if (instance == null)
  {
  instance = FindObjectOfType<T>();
  if (instance == null)
  {
  GameObject obj = new GameObject();
  obj.name = typeof(T).Name;
  instance = obj.AddComponent<T>();
  }
  }
  return instance;
  }
  }

  public virtual void Awake()
  {
  if (instance == null)
  {
  instance = this as T;
  DontDestroyOnLoad(this.gameObject);
  }
  else
  {
  Destroy(gameObject);
  }
  }
}

No, you wouldn’t create the singleton again in the other singleton.

You’d just access the singleton as needed through that other singletons interface.

In your example code though it appears you want to be able to generically access the singleton (using some generic T for the singleton). Not sure why you want this… but if you do, you need to create some generic access point to all singleton.

Without knowing what exactly you’re attempting to accomplish though, I’m not going to go into exactly how to do it, as I may assume something counter to what you actually want.

Of course in the meantime I’ll link to my Singleton abstract class all singletons can implement. It’s a fairly robust Singleton implementation with all sorts of bells and whistles attached to it for use in a scene type setting (where singletons might change out from scene to scene).

and a generic proxy class: