0 votes

Do singletons reset when switching scenes? I've got a character customization system which saves the choices in a global script(singleton). If i print the choices after a scene switch i get the defaults.

in Engine by (399 points)

how do you save it in singleton?
does it work before switching scene?
can you share a sample project to reproduce?

  1. i made a new script and i just put it in the autoload window
  2. yes it works before switching the scene, it print what it should print
  3. i just made the script, made some variables in it, put it in autoload and then acces the variables in another script as global.something, setting them a new value

The question is, it is normal this behaviour?

I liked to know some what was wrong with your project.
what version do you use?
i would make working example project.

I fixed it. I was resetting the global variables on _ready on an object in the new scene

glad to hear that :)

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.