SebLague / Solar-System

Simple solar system experiment
https://www.youtube.com/watch?v=7axImc1sxa0
MIT License
1.16k stars 317 forks source link

Atmosphere disappears when I change the scene #41

Open Kitseru opened 2 years ago

Kitseru commented 2 years ago

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?

Panicat commented 2 years ago

Same now. It used to work fine for me.

Nevermind. Cannot replicate again. It fixed itself.

Panicat commented 1 year ago

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)

Panicat commented 1 year ago

Or try these two things two things that work for me:

  1. Clear() the list effectHolders in PlanetEffects and call Init() (in PlanetEffects.cs as well)
  2. Make the settingsUpToDate bool in AtmosphereSettings.cs public and turn it off after changing the scene