Forum Discussion

🚨 This forum is archived and read-only. To submit a forum post, please visit our new Developer Forum. 🚨
Anonymous's avatar
Anonymous
6 years ago

How to use Cloud Storage in unity

Save data with this method "CloudStorage.Save()"
and Load data with this method "CloudStorage.Load()" ?

How to use that methods?

I want to save user data in user's oculus account like google game service.

How to save user data(level, money, score etc...)

4 Replies

  • rh_galaxy's avatar
    rh_galaxy
    Heroic Explorer
    When you have done the initialization it's ok to use the methods.

    Here is my init for Oculus SDK in a rift game in Unity 2019.2. Wait for bUserValid to be true.

    bool InitOculus()
    {
    if (XRDevice.model.StartsWith("Oculus Rift"))
    {
    //init Oculus SDK
    try
    {
    Core.AsyncInitialize("2005558116207772");
    Entitlements.IsUserEntitledToApplication().OnComplete(EntitlementCallback);
    Users.GetLoggedInUser().OnComplete(LoggedInUserCallback);
    }
    catch (UnityException e)
    {
    Debug.LogException(e);
    UnityEngine.Application.Quit();
    }
    bOculusDevicePresent = true;
    return true;
    }
    return false;
    }

    void EntitlementCallback(Message msg)
    {
    if (msg.IsError)
    {
    Debug.LogError("Not entitled to play this game");
    UnityEngine.Application.Quit(); //it is possible to remove quit while developing
    }
    else
    {
    //ok
    Debug.Log("You are entitled to play this game");
    }
    }

    void LoggedInUserCallback(Message msg)
    {
    if (msg.IsError)
    {
    Debug.LogError("No Oculus user");
    }
    else
    {
    //save ID, and user name
    iUserID = msg.GetUser().ID;
    szUser = msg.GetUser().OculusID;
    Debug.Log("You are " + szUser);
    bUserValid = true;

    myAvatar.oculusUserID = msg.GetUser().ID.ToString();
    }
    }
  • Anonymous's avatar
    Anonymous
    This script is getting user oculus account?
    You know how to save game data in user's account?
    I should submit oculus quest app review for App ID
    Core.AsyncInitialize("2005558116207772")
  • rh_galaxy's avatar
    rh_galaxy
    Heroic Explorer
    No, that's my App Id (sorry for that), you should replace with your App Id... You must register a App Id at the web https://dashboard.oculus.com/

    I don't know how it's done for the quest, I assumed it was for the rift... But to have access to cloud storage I guess that you must have a valid App Id.

    I use Achievements.Unlock() with success after the init is done, so I guess CloudStorage.Save() will work too.

    Edit: I found now how it's done... you must be approved by Oculus to create a Quest App Id...
    https://developer.oculus.com/distribute/publish-create-app/
    https://developer.oculus.com/documentation/unity/ps-setup/?device=QUEST