Is it possible that Unity destroys instances if a application is not active for a while?
I have a static instance of my class GameManager which allows me to access it by any other script in my scene.
I create it on awake if the instance is still null.
It works perfect, but when I test the application I notice that this instance is sometimes destroyed.
I can replicate by running the application in Unity (Personal) on windows.
- I run the application
- Deselect Unity, ie Open explorer or something else.
- Wait a few minutes
- Select Unity again.
When I wait 1 or 2 minutes, nothing happens and I can continue.
If I wait longer I get errors when I try to access the GameManager instance when I returned to the application.
There is no line anywhere in my code that destroys the instance so it must be Unity that is destroying it.