Two questions about static variables

Recently I’ve been doing some research on static variables, but there are a couple questions I haven’t found clarity on.

Lets say I have multiple scenes that do not share variables with each other, and each scene has static variables used for communicating among its own scripts. As far as I’ve been able to learn, static variables exist until the game is shut down, which leads to the following questions.

  1. Will the static variables be intact when I return to and recreate a scene (who previously had all its objects destroyed) and want to update or continue using them?

  2. Is it reasonably possible to have too many static variables add up in the background when switching between many scenes?

A static variable will keep it’s state until you update it or the appdomain closes

Yes a common memoryleak is that you add elements to a collection that is never removed from

1 Like

Thanks for the reply!

It’s good to know that I can still use variables when returning a scene, and I will be careful to make sure they don’t get out of control.