Hey all ! I’m still on 4.25 and just discovered an Unreal behavior I had no idea was a thing and that actually had unintended consequences in my main project I’ve been working on for two years.
In theory opening a new map should discontinue / destroy all the widgets created in the first map, right? At least that’s what I thought.
Except I just realized if the widgets’ references are saved as variables inside a Game Instance blueprint then it’s not the case ! Said widgets just stop being “Top Level” but they’re still there.
To illustrate this I created a simple project from scratch that you can download here.
- Step 1 : on any key pressed, we create a new widget and store its reference in the Game Instance
- Step 2 : on any key pressed, this time we order the widget to wait 3 seconds and Print String “Hello from the grave” and we load another map using “Load Level” node.
- Step 3 : we wait 3 seconds and the Print String DOES trigger
Is this intended behavior ? I had no idea widgets could “persist” between levels, to the point a “Delay” is still working even in a new level. It really mind boggled me.
If the widget is not referenced by the game instance then it does NOT persist between levels (I suppose this has something to do with garbage disposal but I’m not on expert on that topic).
On the contrary if you “Add” the widgets to an array in Game Instance, then none of the widgets ever disappear and you’ll accumulate them every time you change level.
Conclusion : now I’m going to be extra careful about how I’m storing my widgets’ references.
Did y’all already knew this was a thing ?