Is there a way to detect when the game goes to background?

Hi all! I’m interested in calculate every second that the game goes inactive, I already have solved the part when I exit the game, I just save the Date Time and when I open again the game… BUT, I don’t know how to tell the game to save the Date Time when it goes to the background (not terminating the game). Is it actually possible?

Hi there @FranCalvente !

As I read on this thread, it’s not possible yet

One thing you could do is maybe saving the DateTime in a file (or log) every X seconds or something like that

Another thing I read somewhere else, posted 2 alternatives

1 Like

Thanks! that second option you mention worked for me! :slight_smile:

1 Like

That’s how Lyra does it

// Listen for the event
FSlateApplication::Get().OnApplicationActivationStateChanged().AddUObject(this, &ThisClass::OnAppActivationStateChanged);

// Check whether it is minimized right now
FSlateApplication::IsInitialized() && !FSlateApplication::Get().IsActive()