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

Steam VR, stay on background when other VR game is running

Discussion in 'Scripting' started by iebaz, Oct 12, 2016.

  1. iebaz

    iebaz

    Joined:
    Apr 13, 2015
    Posts:
    9
    Hi guys, I need some help please
    I want to build a VR UI Hub app for Steam VR games, I know how to launch external VR games with System.Diagnostics.Process.Start(Application.dataPath + "/shortcut.lnk"); from Unity3d,
    But my app gets closed anytime other VR game is launched.
    How do I make my Unity3d app keep running and when I quit the other game that I launched to then get back to my Hub app?
    I heard about vr_shutdown() and vr_init() but is it for Unity? if it is, where do I plug it in?
    thanks!
     
    Marazyt likes this.
  2. sarahnorthway

    sarahnorthway

    Joined:
    Jul 16, 2015
    Posts:
    78
    I'm able to do this by setting VRSettings.enabled = false before launching the other app, and VRSettings.enabled = true when I detect the other app's process has exited. But to get it to work without crashing, I had to upgrade to Unity 5.5.0b11, and add this line to the top of SteamVR_Render.cs Update:

    if (!UnityEngine.VR.VRSettings.enabled) return;
     
  3. sarahnorthway

    sarahnorthway

    Joined:
    Jul 16, 2015
    Posts:
    78
    Looks like I spoke too soon - it worked several times in a row with Unity 5.5, then went back to crashing or freezing up the child process. I think we should either be able to use VRSettings.enabled=false or VRSettings.LoadDeviceByName("None") but both of those solutions are currently (Unity 5.5) buggy and cause Unity to crash intermittently. I may have to give up on Unity and write a small Windows app to handle switching between the hub and child apps.
     
  4. RaptorX81

    RaptorX81

    Joined:
    Apr 28, 2014
    Posts:
    12
    I'm also running into this issue. I've tried using VRSettings.enabled = false and SteamVR.enabled = false. Doing this followed by starting a SteamVR game causes the Unity game to crash.

    Is the best method to write an external Windows app like sarahnorthway suggests?
     
  5. ibyte

    ibyte

    Joined:
    Aug 14, 2009
    Posts:
    1,043
    Bump
     
  6. Marazyt

    Marazyt

    Joined:
    Jan 23, 2014
    Posts:
    3
    Did someone ever figure this out?
     
  7. Viitorcloud

    Viitorcloud

    Joined:
    May 22, 2018
    Posts:
    3
    still any solution?