How to reset global values when load scene?
See original GitHub issueHi, I created a button to restart my game, but globals are not been reset.
My code is like this:
GameController
private void SetGlobalVars(Contexts contexts)
{
contexts.game.SetGlobals(globals);
}
My function to load scene:
public void Restart()
{
SceneManager.LoadScene(SceneManager.GetActiveScene().name);
}
When the scene has been load, it’s printing error in console about some global value is already setted.
How can I reset my Entitas contexts when the scene is load?
Issue Analytics
- State:
- Created 5 years ago
- Comments:9
Top Results From Across the Web
How to reset global values when load scene? · Issue #690
Hi, I created a button to restart my game, but globals are not been reset. My code is like this: GameController private void ......
Read more >How to reset all variables and objects when reloading a ...
You could use OnSceneLoaded to manually reset your static variables (since they are the only ones that persist without an instance of an...
Read more >Accessing all global variables and resetting them on scene ...
I currently have a few global variables that I use throughout my game. I've found that even if I do a complete re-load...
Read more >Why my Global Variables are reset on another scene
When I change scenes, ALL of my global variables and object variables are reset to their defaults. I have no idea what is...
Read more >Resetting static variables when loading scene with ...
You can't “reload” a static variable. It persists for the lifetime of the app and exists on the heap. Your options are to...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

You can see in the exception which group is getting retained
Collector(Group(AllOf(Asset, View))), Collector(Group(AllOf(Player, PlayerStatus))). Do you save somewhere in a MonoBehaviour a reference to a Entity? As I said you can clear the collectors of reactive systems also withsystems.ClearReactiveSystems().Thanks @StormRene ! cleaning reactive systems just fixed my problems!!!