Last active
December 21, 2022 09:52
-
-
Save dimmduh/016d59a72e22f2cda5bfd98f76ea2ad4 to your computer and use it in GitHub Desktop.
Unity fix dark scene after scene loading (skybox, reflection probe)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using UnityEngine; | |
using UnityEngine.Rendering; | |
//https://forum.unity.com/threads/solved-scenemanager-loadscene-make-the-scene-darker-a-bug.542440/#post-7752681 | |
public class z_DarkSkyboxFix : MonoBehaviour | |
{ | |
IEnumerator Start() | |
{ | |
if (RenderSettings.customReflectionTexture != null) | |
{ | |
yield break; | |
} | |
var baker = gameObject.AddComponent<ReflectionProbe>(); | |
baker.cullingMask = 0; | |
baker.refreshMode = ReflectionProbeRefreshMode.ViaScripting; | |
baker.mode = ReflectionProbeMode.Realtime; | |
baker.timeSlicingMode = ReflectionProbeTimeSlicingMode.NoTimeSlicing; | |
RenderSettings.defaultReflectionMode = DefaultReflectionMode.Custom; | |
yield return null; | |
DynamicGI.UpdateEnvironment(); | |
baker.RenderProbe(); | |
yield return new WaitForEndOfFrame(); | |
RenderSettings.customReflectionTexture = baker.texture; | |
Destroy(gameObject, 1f); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment