Variables' values set in my scripts change by themselves when reloading scenes.

I started building a UI the other day. Everything went fine until I reached a very strange and annoying error…
Okay let me explain. So, I made some buttons that allow me to navigate through menus and also change scenes. These buttons have scripts with values that change the menu’s alpha, the speed for them to open, etc… but here’s the issue. Whenever I change scene and go back to the scene with the menus, these values are all messed up! For example, the alpha value that was set to 1 is now set to 0 and I have no idea where that is coming from. Oh, and the gameobjects inside arrays that are supposed to be opened/closed are getting glitched too, cause they randomly get removed and that results in getting the usual NullReferenceException error. Any idea what is happening? Oh and i’m using Unity 5.5.2. Thanks!

You didn’t really give much info on your setup. But, I’ll toss something out there. If you are in a scene where you have an image and let’s say the default color is blue. But then you change that blue image to green using some buttons. Then you switch scenes and come back, the image will be blue again. Unless you are saving those settings somewhere and then loading them again (like in player prefs) that says when you load up that scene, get the color this image is suppose to be.

Now, this is a guess because you didn’t explain if you were saving settings, if your menu was dontdestroyonload or anything of that nature.

No, i’m not using dontdestroyonload or anything like that, which is why this is bugging me! If you need more information please tell me!

Well…I explained what happen. If you change stuff in a scene and then leave the scene and come back to that scene, nothing saves unless you tell it to. Unless you’re saying the scene is resetting incorrectly.

My example explained what I was trying to say. If you come to a scene with a blue image, even if you change it green and then leave the scene and come back, it’s like you loaded the scene fresh and it’s going to be blue again. It’s not going to stay green unless I save a setting somewhere like playerprefs that says this image should be green when I load it up.

If this isn’t what you are trying to say, I’d need a better idea of what you mean.

Nvm, i’m an idiot. There WAS an object with dontdestroyonload in it(never even noticed it had that method). Thank you for the answers!

Glad you were able to solve it!