XDracam / unity-corelibrary

Collection of classes and extension methods that make life with Unity3D more comfortable
MIT License
16 stars 3 forks source link

Add HasInstance to Singletons to check if destroyed or created yet #65

Open XDracam opened 5 years ago

XDracam commented 5 years ago
public static bool HasInstance => _instance != null;

A common use case is to deregister something from a singleton in OnDestroy, which can cause errors if the singleton has already been destroyed and a new one is created. So we need this property to let people check whether that is the case. Can also be used to safely handle Singleton instances without try/catch.

Might have implications on the Query system.