Search Unity

Check When Game Window is Closed for Windows

Discussion in 'Editor & General Support' started by girlinorbit, Jun 16, 2020.

  1. girlinorbit

    girlinorbit

    Joined:
    Apr 27, 2019
    Posts:
    115
    I'm working on a game for Microsoft Windows and I need to figure out when the user stops playing the game. When I use OnApplicationFocus(bool) it sets as false when I change windows while in play mode in the editor. How can I tell when the window is closed and not when it looses focus?
     
  2. https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnApplicationQuit.html
     
  3. girlinorbit

    girlinorbit

    Joined:
    Apr 27, 2019
    Posts:
    115
    At the bottom, it says:

    Note: On Windows Store Apps and Windows Phone 8.1 there is no application quit event. Consider using OnApplicationFocus event when focusStatus equals false.

    Does this apply to games that aren't downloaded through the app store?
     
  4. I don't think it worth developing Windows Store App which is not sold through the Windows Store. I'm not sure it is possible even.

    You can use this OnApplicationQuit when you make standard desktop applications. Like a game with .exe on windows, or steam application or like that.