Error when loading in Oculus Utilities for Unity — Oculus
Welcome to the Oculus Developer Forums!

Your participation on the forum is subject to the Oculus Code of Conduct.

In general, please be respectful and kind. If you violate the Oculus Code of Conduct, your access to the developer forums may be revoked at the discretion of Oculus staff.

Error when loading in Oculus Utilities for Unity

Zucchini_FredZucchini_Fred Posts: 8
NerveGear
Hi,

When I load in the Oculus Utilities for Unity, I immediately have an error in one of the scripts which reads "Assets/Oculus/VR/Scripts/OVRPlugin.cs(2876,18): error CS0103: The name `OVRP_1_15_0' does not exist in the current context"
How can I deal with this error? Is there a way to locate OVRP or is that no longer a part of the oculus utilities?
Thank You!
«1

Comments

  • luks0rluks0r Posts: 8 Oculus Start Member
    edited June 2018
    I saw this too! I followed the #define code and saw that in the editor, the class definition is #if’ed out, so just do the same by wrapping 

    #if !OVRPLUGIN_UNSUPPORTED_PLATFORM
    #endif

    around the statement groups that are erroring, then you should be on your way!

    I can post the actual lines of code when i get to a computer if you need it. Let me know?

    UPDATE:
    Corrected to read #if !OVRPLUGIN_UNSUPPORTED_PLATFORM
    as it works more accurately than the previously suggested #if !UNITY_EDITOR
  • mitchellhartmitchellhart Posts: 1
    NerveGear
    I'm having the same error. I located the class definition, (private static class OVRP_1_15_0) but mine isn't wrapped in an #if statement. Any ideas? :)
  • luks0rluks0r Posts: 8 Oculus Start Member
    Alright Ocularians, here goes:

    Culprits are all in OVRPlugin.cs:
    #if !OVRPLUGIN_UNSUPPORTED_PLATFORM
    Roughly line 2948. This says "If not a supported platform, do not declare the OVRP_0_X_X classes".

    #if !(UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN || (UNITY_ANDROID && !UNITY_EDITOR))
    #define OVRPLUGIN_UNSUPPORTED_PLATFORM
    #endif
    Line 22-24. These determine if you're on a supported platform or not. If Unity Android target while using the Unity Editor (Play Mode), this makes you in "not supported platform mode", and thus the OVRP_0_X_X classes have not been declared.

    These were not #if'ed out properly, causing the errors. The fixes are all the same, but here's one sample. Add the Bold Italic lines like this around each set of offending code.

        #if !OVRPLUGIN_UNSUPPORTED_PLATFORM
            if (version >= OVRP_1_15_0.version)
            {
                Result result = OVRP_1_15_0.ovrp_GetNodeFrustum2(nodeId, out frustum);
                if (result != Result.Success)
                {
                    return false;
                }
                else
                {
                    return true;
                }
            }
            else
        #endif
            {
                return false;
            }


    Then your scripts should compile and back to dev'ing.

  • NinjaGaijinNinjaGaijin Posts: 188 Oculus Staff
    @Zucchini_Fred Thanks for the heads up! I'm assuming this is happening with the latest Oculus Utilities version 1.27?
    If you need immediate help or want additional support/context on an issue you are having with our platform or integrations:

    1. Gather any and all logs, screenshots, and version numbers of relevant software (Oculus SDK, engine, etc.)
    2. Please submit a ticket here (include what you've gathered in step 1).
    3. Tag me @NinjaGaijin once you have done so!
  • luks0rluks0r Posts: 8 Oculus Start Member
    @NinjaGaijin

    Yup! Just re-downloaded it to reconfirm this. The fix is simply to add these line pairs:

    #if !OVRPLUGIN_UNSUPPORTED_PLATFORM
    #endif
    at lines:
    2876 / 2890,
    2901 / 2917,
    2928 / 2936

    to OVRPlugin.cs

    (these are the line numbers once they're added sequentially). Keep the #endif just after the "else", and then the subsequent "{ return false; }" block works very nicely. (as illustrated in my previous post)

    Thanks!

  • Zucchini_FredZucchini_Fred Posts: 8
    NerveGear
    edited June 2018
    @luks0r

    That fix worked for me but now I'm getting an error related to
    " private const string pluginName = "OVRPlugin"; " 

    Assets/Oculus/VR/Scripts/OVRPlugin.cs(2994,9): error CS1525: Unexpected symbol `const', expecting `class', `delegate', `enum', `interface', `partial', or `struct'

    did this happen to you as well?
  • luks0rluks0r Posts: 8 Oculus Start Member
    @Zucchini_Fred hmm no, best advice I’d say is check to make sure you’ve properly placed your #endif statements. Try reverting to the error'ed version to get back to the "3 errors" state, then #if out one block at a time and see if it removes your error messages one by one.
  • kerskkersk Posts: 82 Oculus Staff
    Hi all, is everyone affected here running the Unity Editor on macOS?
  • pewpewresearchpewpewresearch Posts: 1
    NerveGear
    I am affected by this bug on macOS, and I can confirm @luks0r's fix worked for me.
  • BeingVRBeingVR Posts: 2
    NerveGear
    Yes, MacOS here. Happens on an empty project.
  • mosesoakmosesoak Posts: 6
    NerveGear
    @imperativity I also got these errors on mac and the stated fix worked. This was my first experience trying to develop for Oculus, not much of a confidence builder.



  • mosesoakmosesoak Posts: 6
    NerveGear
    Ah, okay that's helpful, thank you @imperativity – I'll jump over to PC
  • graves3dgraves3d Posts: 5
    NerveGear
    edited June 2018
    i am currently running into this issue with Unity Cloud Build with Oculus Utilities 1.27 targeting Android.

    here is the output from Unity Cloud Build:


    tried implementing the fix suggested by @luks0r, but the end result was the same.
  • mosesoakmosesoak Posts: 6
    NerveGear
    @imperativity It took all day, but I got everything set up and working on PC – I am able to transfer and run a build on the Go. I have another question but I'll ask it on a new thread.
  • mosesoakmosesoak Posts: 6
    NerveGear
    Also, I did get everything to work on MacOS as well eventually. Something had been missed in the billion and one setup steps.

    The docs should more clearly outline or mention the significant setup you need to do in Unity's build settings and preferences. I realize there's also Unreal and you guys aren't here to repeat what Unity manages, but it would be nice to outline it in the same way you outline using adb and other external tools so it isn't overlooked. 

    There is a nice blog post that does walk through everything clearly and simply here, even though it's still an unpleasantly long list of tasks: https://medium.com/inborn-experience/how-to-build-an-app-for-the-oculus-go-from-start-to-finish-with-unity-cb72d931ddae
  • danielladcolldanielladcoll Posts: 3
    NerveGear
    I haven't managed for this to work, keep getting errors when compiling. Would anyone that has managed to make it work (for Mac), please attach a copy of the script to see if it works for me, please?
  • luks0rluks0r Posts: 8 Oculus Start Member
    I'm totally developing an OS X for GearVR / Go, despite it not being officially supported apparently. Anyone feel free to PM me and I should be able to help walk you through this issue (unless you're using Cloud Build)
  • snovaksnovak Posts: 16
    NerveGear
    Also on OSX here, @luks0r fix works.  No support for OSX?  That's lame.   
  • aa_liqueaa_lique Posts: 24 Oculus Start Member
    edited July 2018
    I am Also developing with OS X for GearVR / Go, and having trouble with that same DaRn script error.  With your fix I manage to fix the first problem easily. But then this error popped up next:
    Assets/Oculus/VR/Scripts/OVRPlugin.cs(2907,21): error CS0103: The name `OVRP_1_21_0' does not exist in the current context

    Can you help please?
  • luks0rluks0r Posts: 8 Oculus Start Member
    Yeah! From the line number it looks like you only wrapped one of the three places you have to do this. You need to fix this code in 3 total places, in the morning exact same manner, at these line pairs:

    2876 / 2890,
    2901 / 2917,
    2928 / 2936

    See my previous posts for an example of it if you need a refresher.

    for easy copy / paste, the wrapping is this:
    #if !OVRPLUGIN_UNSUPPORTED_PLATFORM

    and

    #endif
  • garyhausgaryhaus Posts: 2
    NerveGear
    I could really use the help...  I am so very new to the Oculus Go and not a programmer, and I am on a Mac, no choice for dev work... I am not following what you posted as my line numbers are not the same with what you stated.
  • JoeS2018JoeS2018 Posts: 28 Oculus Start Member
    For what it's worth, I too am developing for Go on my Mac — I'm supporting Oculus even though they don't support me.

    Luks0r's fix does the trick on my machine.
  • JoeS2018JoeS2018 Posts: 28 Oculus Start Member
    For what it's worth, I too am developing for Go on my Mac — I'm supporting Oculus even though they don't support me.

    Luks0r's fix does the trick on my machine.
  • brandoncashbrandoncash Posts: 1
    NerveGear
    edited July 2018
    For those Mac users, it's easiest to mark macOS as a supported platform rather than fix each instance of the undefined constant.

    Line 22 of OVRPlugin.cs lists out the criteria to meet to get the "unsupported' flag (OVRPLUGIN_UNSUPPORTED_PLATFORM) which in turn triggers the error that brought everyone to this page.

    Mark macOS as a valid platform by adding UNITY_EDITOR_OSX to the list of platform checks on line 22:
    #if !(UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN || UNITY_EDITOR_OSX || (UNITY_ANDROID && !UNITY_EDITOR))

    Alternatively, you can just comment out line 23 to stop the flag from ever getting set:
    //#define OVRPLUGIN_UNSUPPORTED_PLATFORM


  • garyhausgaryhaus Posts: 2
    NerveGear
    YAYE!  Thank you all so much.  What a birthday gift.  Error is now gone.  I used #if !(UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN || UNITY_EDITOR_OSX || (UNITY_ANDROID && !UNITY_EDITOR)) on line 22

  • aquaSun123aquaSun123 Posts: 7
    NerveGear
    The brandoncash fix works great. I assumed that osx would still be supported, as in, using Unity on a Mac to make Oculus Go apps. Hopefully that makes sense to support.
  • CorysiaCorysia Posts: 1
    NerveGear
    For those Mac users, it's easiest to mark macOS as a supported platform rather than fix each instance of the undefined constant.

    Line 22 of OVRPlugin.cs lists out the criteria to meet to get the "unsupported' flag (OVRPLUGIN_UNSUPPORTED_PLATFORM) which in turn triggers the error that brought everyone to this page.

    Mark macOS as a valid platform by adding UNITY_EDITOR_OSX to the list of platform checks on line 22:
    #if !(UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN || UNITY_EDITOR_OSX || (UNITY_ANDROID && !UNITY_EDITOR))

    Alternatively, you can just comment out line 23 to stop the flag from ever getting set:
    //#define OVRPLUGIN_UNSUPPORTED_PLATFORM


    Thanks for tracking that down, brandoncash!

    Alternatively, you can remove or comment out all three lines:
    //#if !(UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN || (UNITY_ANDROID && !UNITY_EDITOR))
    //#define OVRPLUGIN_UNSUPPORTED_PLATFORM
    //#endif
    I know OSX isn't supported, but like aquaSun123, I develop on OSX sometimes with a target platform of Win64 or Daydream.  Cross compiling shouldn't be stopped by this, but that's the result.  I'm assuming this is a recent change because an older version of the Oculus Utilities didn't give me this grief.
  • OmitaOmita Posts: 3
    NerveGear
    edited August 2018
    If people are still stuck, just use 'Oculus Utilities 1.26' instead until the 1.27 is fixed.

    Otherwise, here is a gist with the OVRPlugin.cs fixes that @luks0r suggested:
    https://gist.github.com/haysclark/62c105b676ac16cee6cd7b38ef62acd1
  • lerabotlerabot Posts: 2
    NerveGear
    edited August 2018
    By the way, you can also add UNITY_EDITOR_LINUX and that will make it work on Linux aswell. I'm building stuff for the GO flowlessly.
    Oculus GO LINUX dev.

    ^ a new SEGA Dreamcast game.

  • miguel_saldanamiguel_saldana Posts: 1
    NerveGear
    UNITY_EDITOR_OSX works, it takes a while to build tho!  :)
    patient... :D
Sign In or Register to comment.