The BepInEx console will not appear when launching like it does for other games on Thunderstore (you can turn it back on in your BepInEx.cfg file). If your PEAK crashes on startup, add -dx12 to your launch parameters.
Decompiled source of Pitch Black PEAK v1.1.0
tony4twentys-Pitch Black.dll
Decompiled a week agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using Photon.Pun; using UnityEngine; using UnityEngine.Rendering; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("Pitch Black")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("Pitch Black")] [assembly: AssemblyCopyright("Copyright © 2025")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("a56511ae-cfa7-4db8-941f-7e56997eb19a")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("1.0.0.0")] namespace Pitch_Black_PEAK; [BepInPlugin("tony4twentys.Pitch_Black_PEAK", "Pitch Black PEAK", "1.1.0")] public class Plugin : BaseUnityPlugin { private Harmony _harmony; public static Plugin Instance; internal static ConfigEntry<KeyboardShortcut> LanternModeToggleKey; private void Awake() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_004c: Unknown result type (might be due to invalid IL or missing references) _harmony = new Harmony("tony4twentys.Pitch_Black_PEAK"); _harmony.PatchAll(); SceneManager.sceneLoaded += OnSceneLoaded; Instance = this; LanternModeToggleKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Lantern", "ModeToggle", new KeyboardShortcut((KeyCode)102, Array.Empty<KeyCode>()), "Toggle Lantern between Omni and Bullseye modes when a *Lantern* is held (not a Torch)."); } private void OnSceneLoaded(Scene scene, LoadSceneMode mode) { NightGlobals.ApplySceneOneShots(); ((MonoBehaviour)this).StartCoroutine(StarterLantern.GiveAfterDelay(15f)); } private void OnDestroy() { try { SceneManager.sceneLoaded -= OnSceneLoaded; } catch { } try { Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } } catch { } } } internal static class NightGlobals { private static readonly int ID_SkyTop = Shader.PropertyToID("SkyTopColor"); private static readonly int ID_SkyMid = Shader.PropertyToID("SkyMidColor"); private static readonly int ID_SkyBot = Shader.PropertyToID("SkyBottomColor"); private static readonly int ID_ExtraFog = Shader.PropertyToID("EXTRAFOG"); private static readonly int ID_brightness = Shader.PropertyToID("brightness"); private static readonly int ID_ambienceStrength = Shader.PropertyToID("ambienceStrength"); private static readonly int ID_ambienceMin = Shader.PropertyToID("ambienceMin"); public static readonly Color SkyBlack = new Color(0f, 0f, 0f, 1f); public const float AmbientBrightness = 0.02f; public const float AmbientStrength = 0.02f; public const float AmbientMin = 0f; public const float LensFlareScale = 0f; public const float NightSfxHour = 23.8f; public const float LavaAlpha_Normal = 0.75f; public const float LavaAlpha_HotBiome = 1f; private static bool _isHotBiome; public static void ApplySceneOneShots() { //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Invalid comparison between Unknown and I4 try { Camera[] array = Object.FindObjectsOfType<Camera>(true); foreach (Camera val in array) { if (Object.op_Implicit((Object)(object)val)) { val.clearFlags = (CameraClearFlags)2; val.backgroundColor = Color.black; Skybox component = ((Component)val).GetComponent<Skybox>(); if (Object.op_Implicit((Object)(object)component)) { ((Behaviour)component).enabled = false; } } } RenderSettings.ambientMode = (AmbientMode)3; RenderSettings.ambientLight = Color.black; RenderSettings.ambientIntensity = 0f; RenderSettings.reflectionIntensity = 0f; RenderSettings.customReflectionTexture = null; RenderSettings.skybox = null; RenderSettings.sun = null; Light[] array2 = Object.FindObjectsOfType<Light>(true); foreach (Light val2 in array2) { if (Object.op_Implicit((Object)(object)val2)) { string text = (((Object)val2).name ?? "").ToLowerInvariant(); if ((int)val2.type == 1 || text.Contains("sun") || text.Contains("moon")) { val2.intensity = 0f; ((Behaviour)val2).enabled = false; } } } DisableByNameToken("sky"); DisableByNameToken("cloud"); DisableByNameToken("clouds"); DisableByNameToken("stars"); DisableByNameToken("atmosphere"); DisableByNameToken("atmo"); DisableMirrorMountains(); _isHotBiome = (Object)(object)Object.FindObjectOfType<Lava>(true) != (Object)null || (Object)(object)Object.FindObjectOfType<LavaPost>(true) != (Object)null; } catch { } } private static void DisableByNameToken(string token) { try { Transform[] array = Object.FindObjectsOfType<Transform>(true); string value = token.ToLowerInvariant(); foreach (Transform val in array) { if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)((Component)val).gameObject)) { string text = (((Object)val).name ?? "").ToLowerInvariant(); if (text.Contains(value) && !IsUnderCanvas(val)) { ((Component)val).gameObject.SetActive(false); } } } } catch { } } private static bool IsUnderCanvas(Transform tr) { try { return Object.op_Implicit((Object)(object)tr) && (Object)(object)((Component)tr).GetComponentInParent<Canvas>(true) != (Object)null; } catch { return false; } } private static void DisableMirrorMountains() { try { Transform[] array = Object.FindObjectsOfType<Transform>(true); foreach (Transform val in array) { if (!Object.op_Implicit((Object)(object)val)) { continue; } string text = (((Object)val).name ?? string.Empty).ToLowerInvariant(); if (!(text == "map") && !text.Contains("[g] map")) { continue; } Transform[] componentsInChildren = ((Component)val).GetComponentsInChildren<Transform>(true); foreach (Transform val2 in componentsInChildren) { if (Object.op_Implicit((Object)(object)val2) && !IsUnderCanvas(val2)) { string text2 = (((Object)val2).name ?? string.Empty).ToLowerInvariant(); if (text2.Contains("mountains")) { ((Component)val2).gameObject.SetActive(false); } } } } } catch { } } public static void ApplySkyBlackout(DayNightManager dnm) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) Shader.SetGlobalColor(ID_SkyTop, SkyBlack); Shader.SetGlobalColor(ID_SkyMid, SkyBlack); Shader.SetGlobalColor(ID_SkyBot, SkyBlack); Shader.SetGlobalFloat(ID_ExtraFog, 0f); try { if ((Object)(object)dnm != (Object)null) { if ((Object)(object)dnm.sun != (Object)null) { dnm.sun.intensity = 0f; ((Behaviour)dnm.sun).enabled = false; } if ((Object)(object)dnm.moon != (Object)null) { dnm.moon.intensity = 0f; ((Behaviour)dnm.moon).enabled = false; } if ((Object)(object)dnm.lensFlare != (Object)null) { dnm.lensFlare.intensity = 0f; } } } catch { } } public static void ApplyAmbientDark() { Shader.SetGlobalFloat(ID_brightness, 0.02f); Shader.SetGlobalFloat(ID_ambienceStrength, 0.02f); Shader.SetGlobalFloat(ID_ambienceMin, 0f); } public static void ClampLavaAlpha() { float num = (_isHotBiome ? 1f : 0.75f); try { float globalFloat = Shader.GetGlobalFloat("LavaAlpha"); if (globalFloat > num) { Shader.SetGlobalFloat("LavaAlpha", num); } } catch { Shader.SetGlobalFloat("LavaAlpha", num); } } public static void ForceNightAmbience(AmbienceAudio a) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)a)) { return; } try { Animator component = ((Component)a).GetComponent<Animator>(); if (Object.op_Implicit((Object)(object)component)) { component.SetFloat("Height", ((Component)a).transform.position.y); component.SetFloat("Time", 23.8f); component.SetBool("Tomb", a.inTomb); component.SetBool("Natureless", false); component.SetBool("Volcano", a.volcano); } } catch { } } } internal static class LanternPresets { public const float BullseyeIntensityMul = 5f; public const float BullseyeRangeMul = 10f; public const float BullseyeSpotAngle = 35f; public const float OmniIntensityMul = 5f; public const float OmniRangeMul = 5f; } internal static class StarterLantern { [CompilerGenerated] private sealed class <GiveAfterDelay>d__2 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public float seconds; private Character <ch>5__1; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <GiveAfterDelay>d__2(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <ch>5__1 = null; <>1__state = -2; } private bool MoveNext() { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForSeconds(seconds); <>1__state = 1; return true; case 1: <>1__state = -1; <ch>5__1 = Character.localCharacter; if ((Object)(object)<ch>5__1 == (Object)null) { return false; } if (HasStandardLantern(<ch>5__1)) { return false; } TrySpawnInHand(<ch>5__1); return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public const ushort StandardLanternId = 42; private const string StandardLanternPrefabName = "Lantern"; [IteratorStateMachine(typeof(<GiveAfterDelay>d__2))] public static IEnumerator GiveAfterDelay(float seconds) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <GiveAfterDelay>d__2(0) { seconds = seconds }; } private static bool HasStandardLantern(Character ch) { try { if ((Object)(object)ch.data != (Object)null && (Object)(object)ch.data.currentItem != (Object)null && ch.data.currentItem.itemID == 42) { return true; } ItemSlot[] array = ch.player.itemSlots ?? Array.Empty<ItemSlot>(); for (byte b = 0; b < array.Length; b++) { Item val = array[b]?.prefab; if ((Object)(object)val != (Object)null && val.itemID == 42) { return true; } } } catch { } return false; } private static void TrySpawnInHand(Character ch) { try { ((MonoBehaviourPun)ch.refs.items).photonView.RPC("RPC_SpawnItemInHandMaster", (RpcTarget)2, new object[1] { "Lantern" }); } catch { } } } [HarmonyPatch] internal static class Patch_DayNightManager { [HarmonyPostfix] [HarmonyPatch(typeof(DayNightManager), "UpdateCycle")] private static void PostUpdateCycle(DayNightManager __instance) { NightGlobals.ApplySkyBlackout(__instance); NightGlobals.ClampLavaAlpha(); } } [HarmonyPatch] internal static class Patch_LightVolume { [HarmonyPostfix] [HarmonyPatch(typeof(LightVolume), "Start")] private static void PostStart() { NightGlobals.ApplyAmbientDark(); } [HarmonyPostfix] [HarmonyPatch(typeof(LightVolume), "SetShaderVars")] private static void PostSetShaderVars() { NightGlobals.ApplyAmbientDark(); NightGlobals.ClampLavaAlpha(); } } [HarmonyPatch] internal static class Patch_AmbienceAudio { [HarmonyPrefix] [HarmonyPatch(typeof(AmbienceAudio), "FixedUpdate")] private static bool PreFixed(AmbienceAudio __instance) { NightGlobals.ForceNightAmbience(__instance); return false; } [HarmonyPostfix] [HarmonyPatch(typeof(AmbienceAudio), "Start")] private static void PostStart(AmbienceAudio __instance) { NightGlobals.ForceNightAmbience(__instance); } } [HarmonyPatch] internal static class Patch_LavaPost { [HarmonyPostfix] [HarmonyPatch(typeof(LavaPost), "LateUpdate")] private static void PostLate() { NightGlobals.ClampLavaAlpha(); } } [HarmonyPatch] internal static class Patch_Character { [HarmonyPostfix] [HarmonyPatch(typeof(Character), "Awake")] private static void PostAwake(Character __instance) { try { if (!((Object)(object)__instance == (Object)(object)Character.localCharacter)) { return; } Light[] componentsInChildren = ((Component)__instance).GetComponentsInChildren<Light>(true); foreach (Light val in componentsInChildren) { if (Object.op_Implicit((Object)(object)val)) { string text = (((Object)((Component)val).gameObject).name ?? "").ToLowerInvariant(); if (text.Contains("characterlight") || text.Contains("playerlight")) { ((Component)val).gameObject.SetActive(false); } } } } catch { } } } internal enum LanternMode { Omni, Spot } internal static class LanternModeToggleImpl { private struct BaseVals { public LightType type; public float range; public float intensity; public float spotAngle; } private static readonly Dictionary<int, LanternMode> _mode = new Dictionary<int, LanternMode>(); private static readonly Dictionary<int, BaseVals> _base = new Dictionary<int, BaseVals>(); internal static bool IsLocal(Lantern ln) { try { return (Object)(object)ln != (Object)null && ((Object)(object)((MonoBehaviourPun)ln).photonView == (Object)null || ((MonoBehaviourPun)ln).photonView.IsMine); } catch { return true; } } private static int Key(Lantern ln) { return ((Object)(object)ln != (Object)null) ? ((Object)ln).GetInstanceID() : 0; } private static BaseVals CaptureBase(Lantern ln) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) int key = Key(ln); if (!_base.TryGetValue(key, out var value)) { Light lanternLight = ln.lanternLight; BaseVals baseVals = default(BaseVals); baseVals.type = lanternLight.type; baseVals.range = lanternLight.range; baseVals.intensity = ln.lightIntensity; baseVals.spotAngle = (((int)lanternLight.type == 0) ? lanternLight.spotAngle : 40f); value = baseVals; _base[key] = value; } return value; } private static LanternMode GetMode(Lantern ln) { int key = Key(ln); if (!_mode.TryGetValue(key, out var value)) { value = LanternMode.Omni; _mode[key] = value; } return value; } private static void SetMode(Lantern ln, LanternMode m) { _mode[Key(ln)] = m; } internal static void SetModeForRPC(Lantern ln, LanternMode m) { SetMode(ln, m); } internal static bool CurrentIsSpot(Lantern ln) { return GetMode(ln) == LanternMode.Spot; } internal static bool IsTorch(Lantern ln) { try { if ((Object)(object)ln == (Object)null) { return false; } Item item = ((ItemComponent)ln).item; string text = (((Object)(object)item != (Object)null && (Object)(object)((Component)item).gameObject != (Object)null) ? ((Object)((Component)item).gameObject).name : string.Empty); if (!string.IsNullOrEmpty(text) && text.IndexOf("torch", StringComparison.OrdinalIgnoreCase) >= 0) { return true; } } catch { } return false; } internal static void Toggle(Lantern ln) { if (!IsLocal(ln)) { return; } LanternMode m = ((GetMode(ln) == LanternMode.Omni) ? LanternMode.Spot : LanternMode.Omni); SetMode(ln, m); Apply(ln); try { ((Component)ln).GetComponent<LanternBullseyeSync>()?.Send(CurrentIsSpot(ln)); } catch { } } internal static void Apply(Lantern ln) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Invalid comparison between Unknown and I4 if (!((Object)(object)ln == (Object)null) && !((Object)(object)ln.lanternLight == (Object)null)) { Light lanternLight = ln.lanternLight; BaseVals baseVals = CaptureBase(ln); LanternMode mode = GetMode(ln); lanternLight.type = baseVals.type; lanternLight.range = baseVals.range; ln.lightIntensity = baseVals.intensity; if ((int)lanternLight.type == 0) { lanternLight.spotAngle = baseVals.spotAngle; } lanternLight.shadows = (LightShadows)0; if (mode == LanternMode.Omni) { lanternLight.type = (LightType)2; lanternLight.range = baseVals.range * 5f; ln.lightIntensity = baseVals.intensity * 5f; } else { lanternLight.type = (LightType)0; lanternLight.spotAngle = 35f; lanternLight.range = baseVals.range * 10f; ln.lightIntensity = baseVals.intensity * 5f; } } } } [RequireComponent(typeof(PhotonView))] internal class LanternBullseyeSync : MonoBehaviour { public Lantern lantern; private void Awake() { if (!Object.op_Implicit((Object)(object)lantern)) { lantern = ((Component)this).GetComponent<Lantern>(); } } public void Send(bool spot) { try { if (!((Object)(object)lantern == (Object)null) && !((Object)(object)((ItemComponent)lantern).item == (Object)null) && !((Object)(object)((MonoBehaviourPun)((ItemComponent)lantern).item).photonView == (Object)null) && ((MonoBehaviourPun)((ItemComponent)lantern).item).photonView.IsMine) { ((MonoBehaviourPun)((ItemComponent)lantern).item).photonView.RPC("SetBullseyeRPC", (RpcTarget)0, new object[1] { spot }); } } catch { } } [PunRPC] private void SetBullseyeRPC(bool spot) { if (!Object.op_Implicit((Object)(object)lantern)) { lantern = ((Component)this).GetComponent<Lantern>(); } if (Object.op_Implicit((Object)(object)lantern) && !(LanternModeToggleImpl.IsTorch(lantern) && spot)) { LanternModeToggleImpl.SetModeForRPC(lantern, spot ? LanternMode.Spot : LanternMode.Omni); LanternModeToggleImpl.Apply(lantern); } } } [HarmonyPatch(typeof(Lantern))] internal static class Patch_Lantern_ModeToggle { [HarmonyPostfix] [HarmonyPatch("OnInstanceDataSet")] private static void PostData(Lantern __instance) { LanternModeToggleImpl.Apply(__instance); } [HarmonyPostfix] [HarmonyPatch("Start")] private static void PostStart(Lantern __instance) { EnsureSync(__instance); LanternModeToggleImpl.Apply(__instance); } [HarmonyPostfix] [HarmonyPatch("LightLanternRPC")] private static void PostRPC(Lantern __instance) { LanternModeToggleImpl.Apply(__instance); } private static void EnsureSync(Lantern ln) { try { if (Object.op_Implicit((Object)(object)ln) && (((Object)(object)((ItemComponent)ln).item != (Object)null && (Object)(object)((MonoBehaviourPun)((ItemComponent)ln).item).photonView != (Object)null) || (Object)(object)((MonoBehaviourPun)ln).photonView != (Object)null)) { LanternBullseyeSync lanternBullseyeSync = ((Component)ln).GetComponent<LanternBullseyeSync>(); if (!Object.op_Implicit((Object)(object)lanternBullseyeSync)) { lanternBullseyeSync = ((Component)ln).gameObject.AddComponent<LanternBullseyeSync>(); } lanternBullseyeSync.lantern = ln; } } catch { } } [HarmonyPostfix] [HarmonyPatch("Update")] private static void PostUpdate(Lantern __instance) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Invalid comparison between Unknown and I4 //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) try { if (LanternModeToggleImpl.IsLocal(__instance) && (!((Object)(object)((ItemComponent)__instance).item != (Object)null) || (int)((ItemComponent)__instance).item.itemState == 1) && !LanternModeToggleImpl.IsTorch(__instance)) { KeyboardShortcut value = Plugin.LanternModeToggleKey.Value; if (((KeyboardShortcut)(ref value)).IsDown()) { LanternModeToggleImpl.Toggle(__instance); } } } catch { } } } [HarmonyPatch(typeof(Lantern))] internal static class Patch_Lantern_InfiniteFuel { private static bool IsFaerieLantern(Lantern ln) { try { Item val = (((Object)(object)ln != (Object)null) ? ((ItemComponent)ln).item : null); string text = (((Object)(object)val != (Object)null && (Object)(object)((Component)val).gameObject != (Object)null) ? ((Object)((Component)val).gameObject).name : string.Empty); return !string.IsNullOrEmpty(text) && text.IndexOf("faerie", StringComparison.OrdinalIgnoreCase) >= 0; } catch { } return false; } [HarmonyPostfix] [HarmonyPatch("SetupDefaultFuel")] private static void PostSetup(Lantern __instance, ref float ___startingFuel, ref float ___fuel) { try { if (!IsFaerieLantern(__instance)) { ___startingFuel = 999999f; ___fuel = 999999f; } } catch { } } [HarmonyPrefix] [HarmonyPatch("UpdateFuel")] private static bool PreUpdateFuel(Lantern __instance, ref float ___fuel) { try { if (IsFaerieLantern(__instance)) { return true; } ___fuel = 999999f; } catch { } return false; } } [HarmonyPatch(typeof(Actions_Binoculars))] internal static class Patch_Binoculars_NightVision { [HarmonyPostfix] [HarmonyPatch("Subscribe")] private static void PostSubscribe(Actions_Binoculars __instance) { try { GameObject gameObject = ((Component)__instance).gameObject; BinocularsNightVision binocularsNightVision = gameObject.GetComponent<BinocularsNightVision>(); if (!Object.op_Implicit((Object)(object)binocularsNightVision)) { binocularsNightVision = gameObject.AddComponent<BinocularsNightVision>(); } binocularsNightVision.Init(__instance); } catch { } } [HarmonyPostfix] [HarmonyPatch("Unsubscribe")] private static void PostUnsubscribe(Actions_Binoculars __instance) { try { BinocularsNightVision binocularsNightVision = (((Object)(object)__instance != (Object)null) ? ((Component)__instance).GetComponent<BinocularsNightVision>() : null); if (Object.op_Implicit((Object)(object)binocularsNightVision)) { ((Behaviour)binocularsNightVision).enabled = false; } } catch { } } } internal class BinocularsNightVision : MonoBehaviour { private const float NV_Brightness = 0.35f; private const float NV_AmbienceStrength = 0.35f; private const float NV_AmbienceMin = 0.03f; private bool _lastActive; private bool _captured; private float _origBrightness; private float _origAmbienceStrength; private float _origAmbienceMin; private Action_ShowBinocularOverlay _overlay; internal void Init(Actions_Binoculars actions) { _overlay = (((Object)(object)actions != (Object)null) ? actions.binocOverlay : null); ((Behaviour)this).enabled = true; } private void Update() { bool flag = (Object)(object)_overlay != (Object)null && _overlay.binocularsActive; if (flag != _lastActive) { if (flag) { EnableNV(); } else { Restore(); } _lastActive = flag; } } private void OnDisable() { Restore(); } private void OnDestroy() { Restore(); } private void Capture() { if (_captured) { return; } try { _origBrightness = Shader.GetGlobalFloat("brightness"); _origAmbienceStrength = Shader.GetGlobalFloat("ambienceStrength"); _origAmbienceMin = Shader.GetGlobalFloat("ambienceMin"); _captured = true; } catch { } } private void EnableNV() { Capture(); try { Shader.SetGlobalFloat("brightness", 0.35f); Shader.SetGlobalFloat("ambienceStrength", 0.35f); Shader.SetGlobalFloat("ambienceMin", 0.03f); } catch { } } private void Restore() { if (!_captured) { return; } try { Shader.SetGlobalFloat("brightness", _origBrightness); Shader.SetGlobalFloat("ambienceStrength", _origAmbienceStrength); Shader.SetGlobalFloat("ambienceMin", _origAmbienceMin); } catch { } } }