//called when GameObject is destroyed void OnDestroy() { if (Instance == this) { Instance = null; } }
// Use this for initialization void Start() { if (Instance == null) { Instance = this; } }