Forum Discussion

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

"Press 'R' to reset orientation" implementation in Unity

Sorry to be such a total noob. I know there have been other posts about this and I have read through them:
viewtopic.php?t=1162
viewtopic.php?f=37&t=20535

I created a script in Unity called RecenterView.js:
#pragma strict

function Start () {

}

function Update () {
if (Input.GetKeyDown("left ctrl"))
{
OVRManager.display.RecenterPose();
}
}


When I return to Unity from MonoDevelop, I have a red ! error message saying:
Assets/Scripts/RecenterView.js(10,25): BCE0005: Unknown identifier: 'OVRManager'.

Once I actually get this script to not have syntax errors, to what element of my project hierarchy will I attach this script?

Without this script, my project compiles fine and displays properly in my DK2.

Thank you kindly for your help.

2 Replies

Replies have been turned off for this discussion
  • Hi BluePotato,

    I'm not a C# developer, but maybe it is because you're not defining a public class?

    Below are the two we use. The first is if we want to call in a reset automatically:

    using UnityEngine;
    public class ResetCamera : MonoBehaviour {
    void OnEnable() {
    OVRManager.display.RecenterPose();
    }
    }


    The next is if we want to call in a reset on user interaction:

    using UnityEngine;

    public class ResetCameraAnyKey : MonoBehaviour {
    // Update is called once per frame
    void Update () {
    if (Input.anyKeyDown)
    OVRManager.display.RecenterPose();
    }
    }


    Hope this helps!