Topic was automatically imported from the old Question2Answer platform.
i made 2 scenes with 2 buttons to switch between them. In the first scene there is a TextureProgress bar and my goal is to store the information of the bar value at any given time while i switch between the scenes. I made a global script and enabled it on the autoload section of the Project Settings menu, using it as singleton.
The scenes works just fine but the bar progress is not stored and remembered when i switch back from scene 2 to scene 1 where the progress bar is located.
I made some screenshots of the entire test project (it’s rather small) and i’m here to ask if someone can help me understand what i’m doing wrong and why the progress bar value isn’t stored and remembered. Thank you all.
I don’t see you reading value of bar1 in your Panel.gd script. I only see you writing to it.
Read bar1 in _ready() and use it, unless it’s null.
Hi, thank you for your answer. Could you be so kind to write me down a code sample? I tried but i really don’t know how to correctly read and use bar1 on _ready() section of the code. It would be so helpful to me since i’m trying to make this work since January 2018 (i know it’s almost unbelievable but it’s the truth).
Kiren | 2019-04-25 05:45
# code you already have in _ready()
if global.bar1 != null:
get_node("TextureProgress").set_value( global.bar1 )
hilfazer | 2019-04-25 06:15
Thank you so much! I want you to know that you made my day. All is working now and i can finally proceed to make my little idle game project working as intended. ^^