Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MissingReference of type CelestialBodyGenerator when changin scene #52

Open
JulienCarrillo opened this issue Aug 4, 2022 · 2 comments

Comments

@JulienCarrillo
Copy link

Hello everyone, I've been struggling for few days with a null ref when I want to reload or change scene.
image
image
image
I feel like the script keeps running when I change scenes. I tried to destroy and re instantiate or disable and enable my script for my planet and my camera but still the same error.

The error seems to come from the PlanetEffects.cs because when I remove it, the error disappears but I have no more ocean or atmosphere.
I also noticed that in runtime, when I refresh PlanetsEffect (line break and save) the error disappears and everything works again.
I'm pretty new to gamedev and I'm sure I'm missing a concept or something.
If anyone can enlighten me that would be great!
I hope I was clear in my explanation.

in advance, thank you

@Delofon
Copy link

Delofon commented Aug 4, 2022

I think you figured out most of it. PlanetEffects.cs, unlike many other scripts, is a scriptable object, which means its instance is always saved. (when in edit mode, it's also saved on the disk) Workaround? Probably would involve making pivate effectHolders list public, clearing it and calling the Init() method when done changing the scene.

Though this is my speculation and I couldn't test it, I believe that's what's going on.

@JulienCarrillo
Copy link
Author

Thanks for your reply :
I tried something like this in my loading system
image
I also made my effectHolders list public. I did the same for the Init method to be able to call them in my loading system, but still the same error. Did I do something wrong?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants