Forum Discussion

🚨 This forum is archived and read-only. To submit a forum post, please visit our new Developer Forum. 🚨
robotloveskitty's avatar
robotloveskitty
Honored Guest
11 years ago

detect if the normal or DirectToRift.exe is launched?

I added a VR mode to my game (Legend of Dungeon) but I still want to be able to let the majority of my players play in normal mode, as they don't have headsets.

Is there a way to detect if the game was launched from the normal exe or the direct to rift one?

I tried OVRManager.display.isDirectMode but that just seems to detect the setting in the configuration utility.
Oh, this is in 0.4.3.1 too.

3 Replies

Replies have been turned off for this discussion
  • I've looked in a couple of previous threads but it seems like there isn't a quick call to figure out which .exe your user launched with. Though, you can write your own which works really well. Here's a snippet of my code that I got inspired to write after another thread on this matter:


    IEnumerator DetectOculus()
    {
    yield return new WaitForEndOfFrame(); // Let Oculus stuff initialize (I needed it for my project)

    long exeSize = 0;
    {
    FileInfo exeFile = new System.IO.FileInfo(Environment.GetCommandLineArgs()[0]); // Path name of the .exe used to launch
    exeSize = exeFile.Length; // exeFile.Length return the file size in bytes. Store it for comparison
    }

    // Use file to determine which exe was launched. This should be stable even if a user changes the name of the .exe or uses a shortcut! =D
    // Direct Rift sizes: 184320 is 64bit size, 32 is 164864 (3rd check is for extended mode(NOT FULLY TESTED))
    // (You may want to use Debug.Log(exeSize); to double check the file size is the same on your match)

    if ((exeSize == 184320 || exeSize == 164864) || (OVRManager.display.isPresent && !OVRManager.display.isDirectMode))
    {
    // DirectToRift.exe
    }
    else
    {
    // Standard.exe
    }


    This might not work if you update the drivers, but I don't think the drivers will change the .exe sizes of older versions so I guess it should keep working.
  • Astiolo's avatar
    Astiolo
    Honored Guest
    Thanks, that solution also worked for me.

    Although I didn't need to yield because I've got the OVR scripts set to run before everything else. I've done it in unityscript and tried to simplify it as much as possible, so I thought I would share my code in case anyone else wants it. I also just set it to check if the exe is below 1MB to avoid any issues of the size changing slightly.

    function detectDirectToRift(){
    var exeFile = new System.IO.FileInfo(System.Environment.GetCommandLineArgs()[0]); // Path name of the .exe used to launch
    var exeSize = exeFile.Length;

    if (exeSize < 1000000){
    cam.useRift=true;
    }else{
    cam.useRift=false;
    }
    }