Values saved in a prefab script changes after entering specific scenes
Hello folks! Last night I ran into a very strange issue that I have been trying so hard to fix (but couldn't).
So here's what I did for my game.
I created a monobehavior script that contains all the values I'd like to keep during the whole game, such as money, upgrades, equipment, unlocked skills, and so on.
Then I attached the script as a component to an empty dummy Game Object, then I made the object a prefab so I can call it whenever I need to use.
It seemed to be working fine. I (the player) could keep all the values even between scenes.
However, yesterday when I made another new scene and tested it, I noticed that I lose all the values like money and exp after entering the new scene. (I was playing from the very beginning of the game until I reach the 'problematic' scene).
At first glance I thought there is something wrong with the new scene, so I manually put some random values in the prefab script and tested on the editor to see if it was the scene. However I was able to keep all the values even after entering and exiting the scene. So I could confirm that there is nothing wrong with the objects in the scene.
Today when I built the game and tried playing it from the scratch, and as soon as I entered the scene that caused the problem before, I found out that my values are resetting AGAIN! However, very strangely, whenever I test entering the scene in the editor I don't see any problem.
Could this be some kind of memory problem? Am I using too much memory space during the gameplay so that it causes to lose my prefab script values at some point and load it again?
It is definitely odd. I have no compiling errors besides some yellow warnings (not the red ones).
Please help!! And thank you so much in advance :)
Your answer

Follow this Question
Related Questions
Help with converting small pseudo script to C# please? 0 Answers
How do I set a default target? 2 Answers
Prefab Script only works when / after I have it highlighted in the project folder while running 0 Answers
How can I in-script create gameobject from prefab? 2 Answers
Create a prefab of custom type 1 Answer