void SceneManagerOnActiveSceneChanged(Scene _, Scene scene) { Logger.Debug($"Scene Change! {scene.name}"); if (_controller == null) { _controller = new GameObject("WorldEffectController"); GameObject.DontDestroyOnLoad(_controller); _particleController = _controller.AddComponent <WorldParticleController>(); _noiseController = _controller.AddComponent <CameraNoiseController>(); bool particleState = ModPrefs.GetBool(ModPrefsKey, "dustParticles", true, true); _particleController.Init(particleState); bool noiseState = ModPrefs.GetBool(ModPrefsKey, "cameraNoise", true, true); _noiseController.Init(noiseState); } if (env.Contains(scene.name)) { _particleController.OnSceneChange(scene); _noiseController.OnSceneChange(scene); } }
public void OnApplicationStart() { SlashParticleMultiplier = ModPrefs.GetFloat(ModPrefsKey, "slashParticleMultiplier", 1, true); ExplosionParticleMultiplier = ModPrefs.GetFloat(ModPrefsKey, "explosionParticleMultiplier", 1, true); try { HarmonyInstance harmony = HarmonyInstance.Create("com.jackbaron.beatsaber.particleoverdrive"); harmony.PatchAll(Assembly.GetExecutingAssembly()); } catch (Exception e) { Logger.Log("This plugin requires Harmony. Make sure you " + "installed the plugin properly, as the Harmony DLL should have been installed with it."); Console.WriteLine(e); } SceneManager.sceneLoaded += SceneManager_sceneLoaded; SceneManager.activeSceneChanged += SceneManagerOnActiveSceneChanged; }