Forum Discussion

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

NullReferenceException

NullReferenceException: Object reference not set to an instance of an object
OVRMainMenu.OnGUI () (at Assets/OVR/Scripts/OVRMainMenu.cs:448)

EDIT: Alternative version!
NullReferenceException: Object reference not set to an instance of an object
OVRMainMenu.Update () (at Assets/OVR/Scripts/OVRMainMenu.cs:361)

Had something like this happen when importing the OVR SDK, but basically created a clean project and imported my assets. Worked fine. Now I play with height on my OVR player controller and a couple of other things and get this error again. I've not deleated any scripts or anything... no changes really.

It displays it once, then when mouse control kicks in it throws hundreds at me.

It happens even in a blank scene with the OVR prefab.

Any ideas?

EDIT: SOLVED - Main Menu script was being an ass. Cut it out. Solved.

5 Replies

Replies have been turned off for this discussion
  • Cut it out?

    I'm getting this error:
    NullReferenceException: Object reference not set to an instance of an object
    OVRMainMenu.Update () (at Assets/OVR/Scripts/OVRMainMenu.cs:361)

    Looks to be the same one you were getting the second time around. It looks to be the reason why I can't Esc to exit my demo, or get the menu to pop up with Spacebar

    What would be the best solution to this?
  • If you want the menu you can change the script execution order and make OVRMainMenu run later. I think that sometimes the MainCamera variable is not setup by the other script before it tries to fetch it when starting.
  • "MichaelSchenck" wrote:
    If you want the menu you can change the script execution order and make OVRMainMenu run later. I think that sometimes the MainCamera variable is not setup by the other script before it tries to fetch it when starting.


    Do you mean it should be the last script (at the bottom), on the OVRPlayerController script list?

    I hadn't touched anything on that object, although I did add a few screen space effects on the OVRCameraController that are working fine.

    Maybe I just need to try a fresh project & import files again.

    Edit: I ended up just changing the Quit key (Esc) to something else, and put in my own quit script in the scene...
  • Just click on any script in the unity editor. Then look at the inspector and there is a script execution order button. Add it to that and make sure it has a positive number so it runs later than the other OVR scripts which will all be default.
  • "MichaelSchenck" wrote:
    Just click on any script in the unity editor. Then look at the inspector and there is a script execution order button. Add it to that and make sure it has a positive number so it runs later than the other OVR scripts which will all be default.

    Genius. Worked!

    I saw another thread where people were commenting on the Esc key being broken. This might be the temporary fix.