Forum Discussion

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

problem detecting if Oculus is on in 0.6.0

Unity version - 5.0.1f1
SDK Version - 0.6.0

Before I wasn't having a problem when my program ran without the oculus being on but now I get this error.

NullReferenceException: Object reference not set to an instance of an object
OVRTracker.set_isEnabled (Boolean value) (at Assets/Standard Assets/ScriptsOVR/OVRTracker.cs:109)
PlayerScript.loadinfile (System.Object inilocation) (at Assets/Scripts/PlayerScript.js:1728)
PlayerScript.Start () (at Assets/Scripts/PlayerScript.js:2196)

I can easily do something different if the oculus isn't on but would like to know the best method for checking whether or not the oculus is on. I've tried "if (OVRDevice.SensorCount > 0)" but i seem to get a similar message to the one above.

Anyone else had this problem?

Cheers

Phil

3 Replies

Replies have been turned off for this discussion
  • xhonzi's avatar
    xhonzi
    Honored Guest
    I'm in a similar situation. I just upgraded to 0.6.0 from 0.4.4 to see if it would solve this problem- but so far it's the same.

    I think it's likely something I'm doing wrong, but I can't tell what.

    I'm trying to detect the Rift- DK1 vs DK2 (vs CV1) as early as possible, but perhaps it's too early. I have a Settings manager in my game- it's where I stuck the code to look out for command arguments such as "-vr" or "-novr" which is working swimmingly. Now I'm trying to auto detect the Rift- it looks like the methods for doing this have seen a lot of change over the past year.

    With DK2, Ovr.Hmd.Detect() is returning -2.

    if (OVRManager.display.isPresent)
    Debug.LogError("Display is Present");
    Returns this error:
    N
    ullReferenceException: Object reference not set to an instance of an object
    Settings.Init () (at Assets/Src/Engine/Core/Settings.cs:197)

    I thought display was static, so I don't have to instantiate it... but Unity is telling me it's not instantiated.

    Do I need to instantiate OVRManager? Is it unavailable until later?

    EDIT: A quick move of that code to the main menu starting up and it's still too early- However, if I enter the game and then return to the Main Menu... then it's fine.

    EDIT2: Sorry for thinking out loud, but it seems I just needed to add the OVRManager script to an object in my "Entry Point" scene, where I am also loading settings. Now I can access it anytime. Huzzah!
  • I'll look at where I'm putting the code myself and see if I can fix it that way. Thanks for the reply. If I managed to get mine working also I'll updated in this post.
  • xhonzi's avatar
    xhonzi
    Honored Guest
    Do reply if you get it working. I'm not sure, but it's possible my current problems are related to the fix I implemented in my post above- adding an OVRManager to the entry point of my game.

    EDIT: Okay, I found my problem with Unity 4.3- In our settings, we allow users to choose between 4 Quality settings- and VSync was only defaulting to ON in the highest. Game defaults to second highest setting, and only Devs with nicer cards were setting it higher. Even so, users can override Vsync settings from our settings menu too, but apparently that setting was taking effect too late to prevent Rift from having resolution errors at startup.

    Adding OVRManager to an earlier part of the game, but not ensuring V Sync was ON that early caused issues.