cancel
Showing results for 
Search instead for 
Did you mean: 

[BUG] Platform Initialization in Unity

delphinius81
Rising Star
Not sure where to submit bugs / incomplete use-case kind of things, but we'll do it here and I'll submit it to the proper channel as needed.

Anyway, my issue is the following: I have a single Unity project which I use to target both a Rift and GearVR distribution. Because I'm targeting multiple platforms, I can't use the provided Oculus Platform -> Settings script to provide an app id, because that id changes depending on my current build target. Ok, no problem, I'll just call the Platform.Core.Initialize() function with the correct appID.

Well, that doesn't work when running in the Unity editor, because the Initialize code is:



public static void Initialize(string appId) {
      if (Application.isEditor) {
        var platform = new StandalonePlatform();
        IsPlatformInitialized = platform.InitializeInEditor();
      } else if (Application.platform == RuntimePlatform.Android) {
        var platform = new AndroidPlatform();
        IsPlatformInitialized = platform.Initialize(appId);
      } else if (Application.platform == RuntimePlatform.WindowsPlayer) {
        var platform = new WindowsPlatform();
        IsPlatformInitialized = platform.Initialize(appId);
      } else {
        throw new NotImplementedException("Oculus platform is not implemented on this platform yet.");
      }
...
}

The bolded line means that even though I'm providing an appId that I want to use for initialization, the function ignores what I want to do and tries to use the editor provided setting instead. If the application is not running in the editor, everything runs as expected using the passed in appId.

So here's the thing: If I pass in an appId to an initialize function, I would expect that the passed in appId will be used. Currently, the function is producing unintended behavior.
2 REPLIES 2

brian_jew
Expert Protege
Thanks for bringing this to our attention.  Looking at code, I can see how this is unclear, and definitely not the expected behavior given the parameter appId is passed.  We'll look into how to correct this.

For background, right now by calling `(new StandalonePlatform()).InitalizeInEditor()`, it'll use the access token that you provided in the same Oculus Platform -> Settings.  While it isn't the smoothest flow, in the mean time you can provide it your access token found in: https://dashboard.oculus.com/application/<your_rift_or_gear_vr_app_id>/api  By giving the access token either for your rift app id or your gear vr app id, it'll switch accordingly.  I hope this helps!

delphinius81
Rising Star
Thanks Brian. That's what I've done right now to become unblocked. Looking forward to the improved flow in a future release!