Atmosphere disappears when I change the scene
When I change the scene or reload the current one (using SceneManager.LoadScene) it seems that the PlanetEffect postprocessing effect no longer works (all the image is black except unlit shaders), and I get the error :
MissingReferenceException: The object of type 'CelestialBodyGenerator' has been destroyed but you are still trying to access it.
and the warning :
OnRenderImage() possibly didn't write anything to the destination texture!
Does anyone know where this is coming from?
Same now. It used to work fine for me.
Nevermind. Cannot replicate again. It fixed itself.
Had it again! Fixed by going to every line where "generator" is null, and adding a null check before that.
For example, adding the following at the start of UpdateSettings():
if (generator == null) return;
(realised this only fixes the error and makes things visible, atmospheres don't show with this method)
Or try these two things two things that work for me:
- Clear() the list effectHolders in PlanetEffects and call Init() (in PlanetEffects.cs as well)
- Make the settingsUpToDate bool in AtmosphereSettings.cs public and turn it off after changing the scene