private void OnDestroy() { if (Instance == this) { Instance = null; // This MonoBehaviour is being destroyed, so set the static instance property to null. } }
private void Awake() { if (Instance != null) { Plugin.Log?.Warn($"Instance of {GetType().Name} already exists, destroying."); GameObject.DestroyImmediate(this); return; } GameObject.DontDestroyOnLoad(this); Instance = this; assetBundle = AssetBundleManager.LoadAssetBundleFromResource($"SpectroSaber.spectrosaber"); }