foxvalleysoccer
5 years agoProtege
Entitlement Check issues
How do I test entitlement? I have this script on my opening screen.
When I build and run on the device all I get is 3 dots. Remove the script my game loads.
In my oculus settings I am logged in with my facebook id same id as I used to create account on my quest and same as oculus dashboard. Should this be a test user account instead of my FB?
public class OculusPlatformEntitlementCheck : MonoBehaviour
{
[Tooltip("Show debug messages")]
public bool debugMode = false;
[Tooltip("Quit app on Entitlement Check Fail")]
public bool quitOnFail = true;
[Tooltip("Standalone mode allows you to initialize the Platform SDK in test and development environments")]
private bool standaloneMode = false;
private string appID = "";
// init params for standalone mode
struct OculusInitParams
{
public int sType;
public string email; // oculus developer account email
public string password; // oculus developer account password
public System.UInt64 appId;
public string uriPrefixOverride;
};
// run on awake
void Awake()
{
//if(debugMode)
// Oculus.Platform.Core.LogMessages = true;
// set the pc app id
appID = Oculus.Platform.PlatformSettings.AppID;
// if on mobile use the mobile app id
#if UNITY_ANDROID
appID = Oculus.Platform.PlatformSettings.MobileAppID;
#endif
// Keep this alive until finished checking
DontDestroyOnLoad(this);
// check for valid appID
CheckAppID();
// check if running in the first scene
CheckScene();
// Asynchronous method (recommended)
if (!standaloneMode)
Oculus.Platform.Core.AsyncInitialize();
// Synchronous method
// if(!standaloneMode)
// Oculus.Platform.Core.Initialize(appID);
//if (standaloneMode)
//Oculus.Platform.InitializeStandaloneOculus(OculusInitParams);
// handle the callback message
Oculus.Platform.Entitlements.IsUserEntitledToApplication().OnComplete(CheckCallback);
}
// check for valid appID
private void CheckAppID()
{
bool badAppID = false;
// handle bad app id
if (appID == "")
{
Debug.LogError("Entitlement Check: Error! missing appID " + System.Environment.NewLine +
" You can create a new application and obtain an App ID from the developer dashboard" + System.Environment.NewLine +
" https://dashboard.oculus.com/");
badAppID = true;
}
if (badAppID)
Debug.LogWarning("Invalid App ID");
}
// check if running in the first scene
private void CheckScene()
{
// check to make sure we're running in the first scene to improve chance of checking within 10 seconds
int sceneID = SceneManager.GetActiveScene().buildIndex;
if (sceneID == 0 && debugMode)
{
Debug.Log("Entitlement Check: Loaded in first scene");
}
else if (sceneID != 0 && debugMode)
{
Debug.LogWarning("Entitlement Check: Not loaded in first scene! " + sceneID);
}
}
// handle the callback message
private void CheckCallback(Oculus.Platform.Message msg)
{
if (!msg.IsError)
{
// Entitlement check passed
if (debugMode)
Debug.LogWarning("Entitlement Check: Passed");
}
else
{
// Entitlement check failed
// NOTE: You may not allow the user to proceed in your app after a failed entitlement check.
Debug.LogWarning("Entitlement Check: Failed!");
Debug.Log("Entitlement Check: Core Initialized " + Oculus.Platform.Core.IsInitialized());
// time since startup check
if (Time.realtimeSinceStartup > 10)
Debug.LogWarning("Entitlement Check: Timeout. Must check within 10 seconds.");
// default to quiting the application on faild entitlement check
if (quitOnFail)
{
UnityEngine.Application.Quit();
#if UNITY_EDITOR
UnityEditor.EditorApplication.isPlaying = false;
#endif
}
}
if (debugMode)
Debug.Log("Entitlement Check: " + Time.realtimeSinceStartup + " seconds");
FinishCheck();
}
// finish the check and cleanup
private void FinishCheck()
{
if (debugMode)
Debug.Log("Entitlement Check: Completed");
Destroy(this);
}
}