Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Windows MR Windowed Mode Close 2D View (Slate/Tile)

Discussion in 'VR' started by David_Giangrave, May 28, 2021.

  1. David_Giangrave

    David_Giangrave

    Joined:
    Feb 21, 2020
    Posts:
    6
    Tech Stack
    Unity 2020.3.x
    OpenXR Plugin 1.2.0
    Mixed Reality OpenXR Plugin 0.9.5
    HP Reverb G2
    Standalone (win32) Application

    Issue
    I use a custom 3D app launcher to start my game, when I have the application start in Fullscreen mode, I get a fullscreen instance show up on the desktop. When I start it in Windowed mode, a tile/slate/2D view appears in the mixed reality home. When I close that panel, the application continues to run in the background which is not desired.

    Question
    How can I kill the game when the 2D view of the application in the WMR home is closed?

    As a follow up question, is there any way I can have both the windowed view in the WMR home as well as on the desktop so that users can kill the application from within the headset or from the desktop?
     
  2. joejo

    joejo

    Unity Technologies

    Joined:
    May 26, 2016
    Posts:
    958
    Check if you have "Run in Background" enabled in Player settings. If so, disable and see if it stops the application from running when you exit the slate window.
     
  3. David_Giangrave

    David_Giangrave

    Joined:
    Feb 21, 2020
    Posts:
    6
    Hi Joejo, thanks for the advice. I have played around with the "Run in Background" setting, however the effect is as follow:
    1. Minimize app on Desktop -> Application Pauses
    2. Go to Mixed Reality Home -> Application Pauses
    3. Close Slate Window -> Application continues running (Because Desktop window is still active)
    4. Close Desktop Window -> Application is Killed
    1 and 2 make perfect sense as the application stops processing while it is no longer in focus, however I would think that 3 and 4 would produce the same result; killing the application.
     
  4. yl-msft

    yl-msft

    Microsoft Employee

    Joined:
    Jul 24, 2020
    Posts:
    10
    In win32 platform, generally, an application can have multiple windows opened, and overlapped. closing one window doesn't always close the other one. In the VR scenario, it is similar, there are 3 windows in this context, A) the window that runs in the headset (immersive view), B) the slate in the cliff house, and C) the window on your desktop monitor. when you closing the slate (B) in the cliff house, the immersive view (A) should also be closed. but the window on your desktop (C) will remain running until user close it, or some application code close it. This is your scenario #3.

    However in scenario #4, I believe when the desktop window (C) is closed, Unity also closed the OpenXR session which leads to immersive view (A) closed. At this moment, your slate window (B) will remain as a slate in cliff house, though it's no longer a running window, but serving as a launching icon for your application.

    I think the difference between #3 and #4 here is that Unity closes the XR experience in scenario #4, but it doesn't close the desktop experience after XR window is closed in scenario #3
     
  5. joejo

    joejo

    Unity Technologies

    Joined:
    May 26, 2016
    Posts:
    958
    I believe that we won't call Quit unless the window is a) the main window or b) the only window. Scenario three sounds like neither of those cases are in action and so there won't be a quit involved.

    The other issue you may be running into is that the windows are not real Unity windows. I.e. Core Unity didn't create them, the external plugin or the OS created them and Unity doesn't know anything about them. In this case there is no way to tell Unity to quit nor do we know that that is the correct action to take.

    You may be able to do something in the c++ code in the generated project that tries to enumerate and hook all window activate events in some way and then force a close if any are closed. However I am not sure how to do that at this time.
     
  6. yl-msft

    yl-msft

    Microsoft Employee

    Joined:
    Jul 24, 2020
    Posts:
    10
    The key here is whether the application can get certain notifications when the XR window is closed. This maps to the OpenXR session state "EXITING". Does Unity XR APIs has any events to notify app C# code for such condition and app can proactively close the desktop window if desired.

    The OpenXR Specification (khronos.org)
     
  7. joejo

    joejo

    Unity Technologies

    Joined:
    May 26, 2016
    Posts:
    958