Guest User

Untitled

a guest
Oct 11th, 2019
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.29 KB | None | 0 0
  1. using Oculus.Platform;
  2. using Oculus.Platform.Models;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. using UnityEngine;
  6. using UnityEngine.UI;
  7.  
  8. public class OculusPlatformManager : MonoBehaviour
  9. {
  10.     public Text logText;
  11.  
  12.     void Start()
  13.     {
  14.         try
  15.         {
  16.             Core.AsyncInitialize();
  17.             Oculus.Platform.Entitlements.IsUserEntitledToApplication().OnComplete(EntitlementCallback);
  18.         }
  19.         catch (UnityException e)
  20.         {
  21.             logText.text = "Platform failed to initialize due to exception.";
  22.             logText.text += "\n" + e;
  23.         }
  24.     }
  25.  
  26.     private void Update()
  27.     {
  28.         Oculus.Platform.Request.RunCallbacks();
  29.     }
  30.  
  31.     void GetLoggedInUserCallback(Message<User> msg)
  32.     {
  33.         if (!msg.IsError)
  34.         {
  35.             logText.text = "Got user " + msg.Data.ID.ToString();
  36.         }
  37.         else
  38.         {
  39.             logText.text = msg.GetError().Message;
  40.         }
  41.     }
  42.     void EntitlementCallback(Message msg)
  43.     {
  44.         if (msg.IsError)
  45.         {
  46.             logText.text = "Entitlement error!";
  47.         }
  48.         else
  49.         {
  50.             logText.text = "Entitlement succeded!";
  51.         }
  52.         Oculus.Platform.Users.GetLoggedInUser().OnComplete(GetLoggedInUserCallback);
  53.     }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment