Search Unity

Project with OVR always builds for Rift, even if not used?

Discussion in 'AR/VR (XR) Discussion' started by Cdngater, Mar 28, 2015.

  1. Cdngater

    Cdngater

    Joined:
    May 29, 2014
    Posts:
    65
    Using the following
    Unity 4.6.3f1
    Oculus Integration 5.0.1

    I have a test project that has an Oculus Camera Rig (enabled) as well as a Main Camera (disabled) in a single scene.

    When I build the project it builds as expected, and when I run either Test.exe or Test_DirectToRift.exe it shows up in my Rift as expect.

    Here is the issue I am having,

    So I go back to my project, disable any Oculus scripts and objects, end enable the Main Camera. In the editor it works as expected, no rift eyes . I build like before, and run either Test.exe or Test_DirectToRift.exe, instead of NOT running in the Rift, it does run in the rift. No rift eyes in Rift either, which is good, just on the wrong screen.

    So am I missing something here? Or is it, if you have the Rift OVR classes and DLLs in your project even if you don't use them, when you build, it builds to use the Rift as the output target regardless?

    Basically I'm trying to create test were I can run it like normal, and then run in in Rift mode, same build executable for both. Can that even be done? I don't want to really be building two separate projects.

    Thanks
     
  2. Todd-Wasson

    Todd-Wasson

    Joined:
    Aug 7, 2014
    Posts:
    1,079
    I'm using the same build for both Rift and non-Rift versions of my software by having the game turn the rift camera rig on or off when it starts, repositioning the world space GUI, etc.. So it is possible to do it with only one build, but I still do need to use the _DirectToRift launcher when running the Rift. This is a small app that looks basically like it's just a setup/launcher type of thing for your main exe, not actually a separate build. So if that's what you mean by two versions then no, I don't know how to get around that. As for the build process itself though, I don't actually do two separate builds anymore.
     
  3. Cdngater

    Cdngater

    Joined:
    May 29, 2014
    Posts:
    65
    Hi Todd,

    Thanks for getting back to me.

    I assume you store your setting?

    Let me ask you a question, if you turn off oculus from within your application and exit. Now restart your application, assuming the setting was saved. Where does your application display? On the monitor or still on the Oculus Rift?

    I have found out from the Oculus Fourms, if you have the Oculus Rift turned on, it will always display there.
     
  4. Todd-Wasson

    Todd-Wasson

    Joined:
    Aug 7, 2014
    Posts:
    1,079
    No, I just detect whether the Rift is connected or not when the game starts.
     
  5. Cdngater

    Cdngater

    Joined:
    May 29, 2014
    Posts:
    65
    Hum, so to force it to not detect the rift, you either unplug the rift, or turn if off?

    Alright, maybe I need to change my thinking about this.

    I was hopping to do like some of the commercial games do were you are not forced to use the oculus rift if it's turned on, but maybe that's just not possible with unity.

    Quick question about your auto detect, you just checking the is present function on ovrmanager?
     
  6. davem250

    davem250

    Joined:
    May 28, 2013
    Posts:
    186
    Just a question regarding the Commercial games Rift setting, are you sure they're even using Unity??? I am not saying that they're not using Unity but i have never experienced this as a possibility at least with Unity, but i might have overseen some things with the Oculus SDK?!
     
  7. Cdngater

    Cdngater

    Joined:
    May 29, 2014
    Posts:
    65
    No, I expect they are not using unity, I'm just using them as an example if what I would have expected to do with unity.

    Not even UE4 and the oculus forces you to use the rift. You have to go to the console and enable it which also be done via blueprints. But I have spent too much in unity3d to throw it all away and switch to UE4, so I'm just trying to get unity to do the same thing.
     
    Last edited: Mar 29, 2015
  8. Todd-Wasson

    Todd-Wasson

    Joined:
    Aug 7, 2014
    Posts:
    1,079
    I have a Start() function somewhere with this tucked in it:
    Code (csharp):
    1.  
    2. GameManager.riftMode = OVRManager.display.isPresent;
    3.  
    I then use my GameManager.riftMode in a few places throughout the game to decide what to to do with the cameras, GUI, and so forth.

    I haven't really given this a lot of thought yet. You raise a good point in that people may have their Rift plugged in even when they're not using it. I run a triple monitor setup so I'm forced to unplug two of the monitors and plug in the Rift any time I want to use it. It didn't even occur to me that most people are probably running one monitor. So it looks like I'm the one that needs to do some rethinking. :)

    It will probably just be a matter of adding a few more ways for my GameManager.riftMode to get turned on or off. I have no intention of having it do that while the game is actually running, although it remains to be seen if that's a smart thing to do or not. The way I see it right now, I don't worry about them unplugging thier monitor, keyboard or mouse either, so why write special stuff to handle that? I figure they have to choose _DirectToRift mode to run it in the Rift anyway, so maybe most people will turn it on first. If they started a regular game with their monitor turned off, surely they wouldn't expect it to work.

    I don't know though, people do weird things. Maybe this will be something that needs to be handled unless we all do it pretty much the same way so experience teaches them that any time they're playing a Rift game, they need to turn the thing on before starting the game. Time will tell, I really don't know.

    Anyway, you can do what you want in Unity. Maybe have it load into a first scene where they are forced to choose Rift or not. But then again, they have to use _DirectToRift mode anyway to run on the Rift, right? So they're deciding before the game even starts either way.

    If that _DirectToRift mode ever goes away, it could still be done probably. I just do transform.parent on the rift camera rig to tie it to the current active regular camera object. I haven't tested it while the game's running, but maybe if I SetActive(false) the Rift camera rig, the regular camera might start working again? Not sure, maybe you can try it. Now that you said that, I'm curious if turning the power off causes that function to return false. I'd think it would, but don't know.
     
  9. Todd-Wasson

    Todd-Wasson

    Joined:
    Aug 7, 2014
    Posts:
    1,079
    As far as I know all the Unity Rift games have that _DirectToRift.exe launcher. So if you see that you know it's a Unity game.
     
  10. Cdngater

    Cdngater

    Joined:
    May 29, 2014
    Posts:
    65

    Hey Todd, thanks for getting back to me. Your code snippet it what I was expecting, thanks for confirming.

    I'll test your question later tonight, but still, asking the user to turn off/on their rift just because we can not do it properly via software just seems wrong to me.
     
  11. Cdngater

    Cdngater

    Joined:
    May 29, 2014
    Posts:
    65
    Two of the comercal games I'm talking about is, Elite Dangerous, and Star Conflict. Neither of them will force you to run in rift mode because you just happen to forget to turn the device off. Where as with unity, it will.
     
  12. Todd-Wasson

    Todd-Wasson

    Joined:
    Aug 7, 2014
    Posts:
    1,079
    Interesting. Is there a Rift selector in the game options then?
     
  13. Cdngater

    Cdngater

    Joined:
    May 29, 2014
    Posts:
    65
  14. Cdngater

    Cdngater

    Joined:
    May 29, 2014
    Posts:
    65
    Ok, finally found time tonight to answer the question. Turning the rift off and on while in a unity game will lock up each time at least for my test. Oh well.

    Anyway, so starting the app with the rift turned on will show stereo on the rift. Starting the app with the rift turned off will show on the monitor. I guess I can live with that for now, it's not professional, but it works.

    So I'm thinking the next step would be to allow resolution change from within the app when not running rift mode. Should be easy enough.

    I'll consider this closed unless someone has a idea.

    Thanks Todd and everyone else who piped in.