Search Unity

HMDAcquired()

Discussion in 'AR/VR (XR) Discussion' started by HamFar, Jan 26, 2015.

  1. HamFar

    HamFar

    Joined:
    Nov 16, 2014
    Posts:
    89
    Hello,

    I have the following code snippet in a Unity application that used DK1:

    Code (csharp):
    1. if ( OVRDevice.IsInitialized() && OVRDevice.IsSensorPresent() && OVRDevice.IsHMDPresent() )
    2. {
    3.     print( OVRDevice.IsSensorPresent() );
    4.     oculusPresent = true;
    5.     standardController.SetActive( false );
    6.     sounds.TheController = oculusController.GetComponent<CharacterController>();
    7.     transform.parent = oculusController.transform;
    8. }
    9.  
    Now that I am migrating the app to use DK2, of course I am first replacing all references to OVRDevice with OVRManager, but I wonder what would be the best way of updating this block of code, because there is the boolean variable ovrIsInitialized and the method OVR_Initialize() and a few other things...

    I am going through the OVRManager file, but as a beginner, I find it a bit difficult to figure out how to do this in a succinct manner. I did notice though the HMDAcquired() method, so I tried to simply replace the first line of the old code with the following:

    Code (csharp):
    1. if ( OVRManager.HMDAcquired() )
    However, I get an error message that reads:

    error CS0070: The event 'OVRManager.HMDAcquired' can only appear on the left hand side of += or -= when used outside of the type 'OVRManager'

    What am I doing wrong with HMDAcquired() and how can I re-write the old code using the new DK2 functions in an elegant way?

    Thank you,
     
  2. virror

    virror

    Joined:
    Feb 3, 2012
    Posts:
    2,963
    HMDAcquired() is not a function, its an event so thats why you cant use it like that.
    You can use OVRManager.display.isPresent to detect if a display are connected and OVRManager.tracker.isPresent to check if a tracker are connected.
     
    HamFar likes this.
  3. HamFar

    HamFar

    Joined:
    Nov 16, 2014
    Posts:
    89
    *

    Thank you! I now see what I was doing wrong...

    I do, however, not get anything in return when I use the following code in my Start() though:

    Code (CSharp):
    1. if ( OVRManager.display.isPresent && OVRManager.tracker.isPresent )
    2.             Debug.Log ( "Both display and tracker are present!" );

    But when I use the following, it works:

    Code (CSharp):
    1. if ( Ovr.Hmd.Detect() > 0 )
    2.             Debug.Log ( "Rift detected!" );
    Have you had this problem before?

    *