- Home /
Force lighting update or detect when they happen?
Hi
I'm using the URP to do lighting in my 2D game and I've been loving it. I'm using the experimental 2D renderer and it achieves exactly what I want, minus one issue I'm having.
I have a global 2D light that controls the sunlight in my game, that exists on a persistent scene with various managers and the like. My games tilemaps and other scenes are loaded additively. When I change scenes I have a blackscreen fade in. Once it's fully faded I unload the current scene, then load a new one. I have no issues with any of this behavior during 99% of the playtime and the way things are setup work perfectly, except here comes the issue.
When you first load the persistent scene, the light takes longer to update than it takes for everything else to load, so the fade from black occurs and the light finally updates while stuff is visible. It doesn't cause any major issues, but is a little ugly. In the short term I got around it by simply delaying the very first fade by 1 second, but this feels like a more hacky workaround than I'd like. All of the scene loading happens in coroutines, so the fade from black normally happens at the precise moment everything's finished loading, leading to the delay to the player being no longer than absolutely necessary (This is important as depending on what you're doing it's possible to be hopping between scenes fairly quickly.)
What I'm wondering, is there a way to either force the light to update sooner, or to detect when the lighting has updated so I can delay the fadein until exactly then?