Why would UI elelments only update when the game is *not* in focus?

I have created several UI elements to represent 3 status bars for a player. I also have a custom event chain that fires from my CombatStats module and updates the % and numerical display of health / armor / shield.

I have added break points to the functions so I know the event chain is working that way and the back-end is updating as the values change in expected ways.

However, the graphical portion of the UI does not update unless the engine is NOT in focus.

IE I click “play” from the editor and let the game load. I can run around and such, then if I hit the Windows key to release the mouse and select a different program, with the engine still simulating in the background, I can watch the ui update as I expect.

What am I missing/doing wrong?

You can turn on
“Use less CPU when in Background” in the editor preferences. But there is no specific logic to freeze the ui on loss of focus.

You could implement your own logic to control this
example:

And then just set the ui tick to a very large value on loss of focus and that will nearly pause it.

You have what is happening backwards.

Currently the game ONLY updates the UI when NOT in focus. When the game is the active application the UI elements do not update.

What exact logic is driving the updates of the UIs?
Are you using

  • bind logic from within UMG
  • event driven from an actor => to UI.
  • some form of tick update either in actor or widget.

Maybe check if you have more than one instance of the engine open at the same time (Look through task manager). Maybe a duplicate instance of the engine running could be introducing some weird behavior.
Sometimes if an engine instance crashes it can leave behind a running process.

Does this happen if you try running “standalone game” or even after packing?

I actually think I figured out what it was. The “ticks” in the engine were happening so fast while it was in focus and my regeneration was so slow/misprogrammed that there wasn’t enough time passing in between those ticks for even a single point of health to regenerate. But when it is out of focus the ticks are further apart so it was able to generate health.