cancel
Showing results for 
Search instead for 
Did you mean: 

Cloud/Data storage?

pjenness
Rising Star
Hiya

Im wanting to store game/app specific player data for when the player come back and plays again. In particular stuff like preferences and stats. So Im mainly storing numbers and strings.

Is this what cloud storage is for? If so are there any tutorials examples of doing so using Unity and Platform?

Thanks!

-P
Drift VFX Visual, Virtual , Vertical Want 970GTX on Macbook for good FPS? https://forums.oculus.com/viewtopic.php?f=26&t=17349
10 REPLIES 10

charles_beyer
Protege
Cloud storage was designed to holder larger chunks of data, like a game save.  Nothing prevents you from storing smaller things, but then you have to worry about performance and consistency issues.  Consistency meaning, you have to be careful that all values are synchronized between all devices before using them.  So if you can serialize your stats to one structure to save, that would be better.  There is not a good Unity sample yet beyond demonstrating the API calls in Samples/UnitySample/PlatformSample.  There is a native sample that demonstrates all the complexity of cloud storage and conflict resolution in Samples/CloudStorageExample.  Hopefully we can add a more complete Unity sample when Android support is finished.

pjenness
Rising Star


Cloud storage was designed to holder larger chunks of data, like a game save.  Nothing prevents you from storing smaller things, but then you have to worry about performance and consistency issues.  Consistency meaning, you have to be careful that all values are synchronized between all devices before using them.  So if you can serialize your stats to one structure to save, that would be better.  There is not a good Unity sample yet beyond demonstrating the API calls in Samples/UnitySample/PlatformSample.  There is a native sample that demonstrates all the complexity of cloud storage and conflict resolution in Samples/CloudStorageExample.  Hopefully we can add a more complete Unity sample when Android support is finished.



Hiya

Where those unity examples for cloud?   IN the Oculus Platform package I only have scripts. AM I missing some demo sample scenes?

Are there good examples of how Cloud works. I dont need to store a huge amount. Just configuration information for the player, so settings get remembered on next visit (or level change if needed)

Thanks!!

-P


Drift VFX Visual, Virtual , Vertical Want 970GTX on Macbook for good FPS? https://forums.oculus.com/viewtopic.php?f=26&t=17349

pjenness
Rising Star
I just tried updating to 1.10 but still cant find any examples.

Samples/UnitySample/PlatformSample is very raw and errors i the editor for me...it also doesn't seem to have cloud (unless I'm looking int he wrong place)

Does cloud save data to the personal user (is userID keyed storage) so that I do not have to specify the user whose data is getting stored?

So for example if I wanted to save my character info lets say

For player "pjenness"  ie me, I want to store

avatarName (string)
level (int)
items ["item1",item2","item3"]
timeSpentPLaying (float)

How do I store that data with this command

Oculus.Platform.CloudStorage.Save(bucket_name, key, data_pointer, data_size, counter, extra_data)

bucket name and key I understand, but not how to use the other parameters










Oculus.Platform.CloudStorage.Save ("PlayerInfo", "avatarName" , ??  , ??, ??);

Oculus.Platform.CloudStorage.Save ("PlayerInfo", "level" , ??  , ??, ??);

Oculus.Platform.CloudStorage.Save ("PlayerInfo", "items" , ??  , ??, ??);

Oculus.Platform.CloudStorage.Save ("PlayerInfo", "timeSpentPLaying" , ??  , ??, ??);


Help and examples would be appreciated.

And also the correct way to read and deal with the requested return values from load

Cheers

-P
















Drift VFX Visual, Virtual , Vertical Want 970GTX on Macbook for good FPS? https://forums.oculus.com/viewtopic.php?f=26&t=17349

pjenness
Rising Star
OK trying to get a bit further...help would be appreciated:

I grabe the user and ID








  private void GetLoggedInUserCallback (Message msg)

  {
   if (!msg.IsError) {

      m_OVRuser = msg.GetUser ();
  m_
PlayerID  = m_OVRuser.OculusID;
    }
  }




Then later I want to save info








  void doSaveLocalPlayerInfo ()

  {

    if (m_OVRuser != null) {

      string AvatarName = "myAvatarName";

      byte[] avatarNameBytes = new byte[100];
      avatarNameBytes = System.Text.Encoding.ASCII.GetBytes (AvatarName);

//Saving an entry with a key prefixed by the playerID. EG playerID_AvatarName
      CloudStorage.Save ("PlayerInfo", (m_PlayerID + "_AvatarName"), avatarNameBytes, 100, "");

    }

  }



  void doLoadLocalPlayerInfo ()

  {
    if (m_OVRuser != null) {
      string PlayerID = m_localPlayerName;
      byte[] avatarNameBytes = new byte[100];

    // HOW DO I CAPTURE THIS DATA??? SOMEHOW INTERCEPTING A REQUEST ??//  
avatarNameBytes = CloudStorage.Load ("PlayerInfo", (PlayerID + "_AvatarName"));

      m_localPlayerAvatarName = System.Text.Encoding.ASCII.GetString (avatarNameBytes);



    }

  }







Drift VFX Visual, Virtual , Vertical Want 970GTX on Macbook for good FPS? https://forums.oculus.com/viewtopic.php?f=26&t=17349

dvir
Explorer
@pjenness: Similar to all other asynchronous methods in the SDK, `CloudStorage.Save` and `CloudStorage.Load` are of type `Request<>`. They both have a method called "OnComplete", which takes a delegate (or a callback) to be executed once the request has finished.

In your example:
  CloudStorage.Load ("PlayerInfo", (PlayerID + "_AvatarName")).OnComplete(delegate(Message<CloudStorageData> message) {
if (message.IsError) {
Debug.Error("CloudStorage.Load error: " + message.GetError().Message);
return;
}
m_localPlayerAvatarName = System.Text.Encoding.ASCII.GetString (message.GetCloudStorageData().Data);
});




Note though: the CloudStorage API doesn't work through Unity's Play Mode. You'll have to build and run it as a standalone build (File -> Build and Run).

pjenness
Rising Star
Thank you very much @dvir

Will give this a go!!

-P
Drift VFX Visual, Virtual , Vertical Want 970GTX on Macbook for good FPS? https://forums.oculus.com/viewtopic.php?f=26&t=17349

pjenness
Rising Star
@dvir

MANY MANY Thanks..... finally got cloud storage working for Unity!!
The Docs are very unclear (for those not so familiar with setting it up for first time).

Really appreciate the help!

-P





Drift VFX Visual, Virtual , Vertical Want 970GTX on Macbook for good FPS? https://forums.oculus.com/viewtopic.php?f=26&t=17349

charles_beyer
Protege
pjenness, feedback noted.  Sorry, the Unity samples do not yet include a good Cloud Storage example.  Also, the issue with CloudStorage not working with the stand-alone client (Unity Play mode) is unfortunate and something we're hoping to fix as we add Gear VR support.  Thanks @dvir for helping!

james_lue
Explorer
Hi, I tried v1.25 these days. It seems that CloudStorage in Unity Play mode still doesn't work. Is there any other way to test CloudStorage without actually building the app?