cancel
Showing results for 
Search instead for 
Did you mean: 

Step by Step Entitlement in Unity

adeade
Explorer
Hello, i hope someone can help me.I am new at Unity Development and have developed my first game.

After uploading in Dashboard(Oculus) and checking through Oculus team. i have to do entitlement.

My english is not very good, so i have problems to get what ecactly i have to do at the developer site.

for now i done the following.

1. First step i  have installed In Unity 5.50B2  the Oculus Platform .
2. Then i click on edit settings and on the inspector i add my oculus rift app ID.

But is this enough ?can i build the game and upload to dashboard ?

in the same time i read other sites and there they often do more steps and add code or other things.
Therfore i create a empty game object in my game , created then a C script and put the following code inside.
Code:









using UnityEngine;

using System.Collections;

using Oculus.Platform;

using UnityEngine.Events;



public class EntitlementManager : MonoBehaviour {



    public string appId;



    void Start(){

        Oculus.Platform.Core.Initialize(appId );

        Oculus.Platform.Entitlements.IsUserEntitledToApplication().OnComplete( EntitlementChecked );

    }



    void Update(){

        Request.RunCallbacks();

    }



    void EntitlementChecked(Message msg){



        // Ok

        if (!msg.IsError){

            // Do what you want, load main menu

        }

        // Not Ok

        else{

            UnityEngine.Application.Quit();

        }

    }



}





Now when i start Play mode in Unity the following message appear.
"" The 'Oculus App Id (12xxxxxxxxxxxxx)' field in 'Oculus Platform/Edit Settings' is clobbering appId (12xxxxxxxxxxxxx) that you passed in to Platform.Core.Init.  You should only specify this in one place.  We recommend the menu location""


I think its clear that i have to deactivat now the script or the Menu Location.

But my questions is, for example if i deaktivat the Menu location, then only the script is active ?
Is this enough ? (or better solutiuon?)

Or should i activat the Menu location , is this still enough ?

And how i can check if `the entitlement its working ?

Perhaps someone can answer me my question,or better give me a step by step tutorial.
thank you


best regards
Rockyade





































1 ACCEPTED SOLUTION

Accepted Solutions

delphinius81
Rising Star
That's it! I believe the user token is for testing on a computer that does not have oculus home installed (e.g. on a mac). I think it lets you to simulate a logged in user. But you don't need that for submission to the store.

View solution in original post

10 REPLIES 10

delphinius81
Rising Star
You are seeing that message because you have entered the appID both through the Unity Editor (in the platform settings window) and also are providing it through code. It's actually safe to ignore assuming the appIDs match. However, if you want to get rid of it, in your Start function you can just do:

Oculus.Platform.Core.Initialize(); //  Notice I took out the appID parameter, it is supplied automatically if you put it into the platform settings window

Also, you do not have to call Request.RunCallbacks(); in Update anymore. That was only necessary in the first couple sdk versions.

Otherwise, everything looks correct.

adeade
Explorer
Hello thank you for the answer.
if i understood it right i can do the following.

1. i use the platform window and enter there my appID.
2.  in addition to that i aktivat my script at the empty gameobject and in the code i remove  my appid .

Then the code look like :
using UnityEngine;

using System.Collections;

using Oculus.Platform;

using UnityEngine.Events;



public class EntitlementManager : MonoBehaviour {



    public string appId;



    void Start(){

        Oculus.Platform.Core.Initialize( );

        Oculus.Platform.Entitlements.IsUserEntitledToApplication().OnComplete( EntitlementChecked );

    }





    void Update(){

      

    }





    void EntitlementChecked(Message msg){



        // Ok

        if (!msg.IsError){

            // Do what you want, load main menu

        }

        // Not Ok

        else{

            UnityEngine.Application.Quit();

        }

    }



}





And this will work then if the Oculus team check the entitlement after i upload a new build to the dashboard ?
or is there any other things to do ?

for example do i need " get user token  ? " in the oculus platform settings

Thank you
best ragards
Rockyade






delphinius81
Rising Star
That's it! I believe the user token is for testing on a computer that does not have oculus home installed (e.g. on a mac). I think it lets you to simulate a logged in user. But you don't need that for submission to the store.

adeade
Explorer
Thanks a lot.

simonindelicate
Explorer
Hi, Just wanted to post as I wrestled with this question for an annoyingly long while and wanted to post what worked for me on the thread that turned up in google the most... I think there's a bit of a clarity issue with the documentation on this part of the process for people who are a bit shaky with scripting in C# - perhaps because, like me, they stupidly learned unityscript instead before they found out that no one does that.

So for anyone who ends up here looking for a sample script, this is what worked for me (building for PC):

Import the Platform SDK and enter your AppID into the settings.

Attach a New Script called "Entitlements.cs" to an empty GameObject in your first scene and use this code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
using Oculus.Platform;
using UnityEngine.SceneManagement;


public class Entitlements : MonoBehaviour {

    public GameObject ErrorMsg;
    public bool quitting;

    void Start () {
        Oculus.Platform.Core.Initialize();
    }

    void Update (){
        CheckApplicationEntitlement ();
    }

    public void CheckApplicationEntitlement() {
        Oculus.Platform.Entitlements.IsUserEntitledToApplication().OnComplete(callbackMethod);
    }

    void callbackMethod (Message msg)
    {
        if (!msg.IsError)
        {
            Debug.Log ("yep");
        }
        else
        {
            Debug.Log ("nope");
            if (!quitting) {
                StartCoroutine (quitApp ());
                quitting = true;
            }
        }
    }

    IEnumerator quitApp ()
    {
        Instantiate (ErrorMsg);
        yield return new WaitForSeconds (5);
        UnityEngine.Application.Quit ();
        Debug.Log ("hasQuit");
    }


}
For the variable that turns up in the editor, make a Prefab out of (say) a worldspace canvas in front of the camera with an error message on it and drag it to 'ErrorMsg'.

This script will perform the entitlement check and, if it fails, it will instantiate your error message canvas, wait 5 seconds then quit the application.

If it passes it will just carry on with whatever your scene was going to do anyway.

I expect this is very much a less than perfect solution but as someone who was getting quite smug about how they were doing at unityscript and then ran into the C# only docs for this - I'm just pleased that it worked.

If you need to test that it's working in the preview, just deleting the last digit from the AppID in the platform settings will make the check fail, trigger your error message and print 'hasQuit' when it's supposed to quit.

Hope that's of use to someone.





Lightowl
Explorer
I am getting this error message when trying to implement entitlement checking:

DllNotFoundException: LibOVRPlatform64_1
Oculus.Platform.WindowsPlatform.AsyncInitialize (System.String appId) (at Assets/OculusPlatform/Scripts/WindowsPlatform.cs:43)
Oculus.Platform.Core.AsyncInitialize (System.String appId) (at Assets/OculusPlatform/Scripts/Platform.cs:71)
OculusEntitlementCheck.Start () (at Assets/A - Scripts/OculusEntitlementCheck.cs:25)

The steps I have taken:
1. Imported latest Oculus Platform SDK
2. Entered my App ID in the Oculus Platform settings
3. Added a GameObject with a script to check for entitlement


The script that I used....
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Oculus.Platform;
//note: Must have Oculus Platform SDK for Unity installed!
public class OculusEntitlementCheck : MonoBehaviour
{
    // Use this for initialization
    void Start()
    {
        Core.AsyncInitialize();
        Entitlements.IsUserEntitledToApplication().OnComplete(
          (Message msg) =>
          {
              if (msg.IsError)
              {
                  print("fired oculus platform, is not entitled");
              // User is NOT entitled.
              UnityEngine.Application.Quit();
              //showMessageThatTheUserDoesntOwnThis();
          }
              else
              {
                  print("Oculus platform entitlement check passed");
              // User IS entitled
              //proceedAsNormal();
          }
          }
        );
    }
}

What am I missing??? I am using Unity 5.6 and the latest Oculus platform SDK (1.15 I believe)

I tried the code above this comment and also got an error message albeit a different one in addition to the one I mention above.

I am using the latest SDK...is that the problem?



delphinius81
Rising Star
In build settings, do you have x86_64 set as the target architecture?

Lightowl
Explorer
@delphinius81  - yes I do.

Pierre_FR
Protege
To check if your entitlement is working, try:
Start your game/app, then logout Oculus Store while the game/app is still running.
In that case you should print a message then exit the game/app.

Don't forget that part:

void Update ()
{
    Oculus.Platform.Entitlements.IsUserEntitledToApplication().OnComplete(callbackMethod);
}