Forum Discussion

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

Cloud Storage V2: How do i use it in Unity?

Hi

I want to use Cloud Storage 2 for my Oculus Quest 2 Unity game.  I have read https://developer.oculus.com/documentation/unity/ps-cloud-storage/?locale=en_GB but I can't figure out how to use Platform.CloudStorage2.GetUserDirectoryPath()

 

I want to get a string which is the path of the directory for me to save my game data into for it to be Cloud Sync'ed, but GetUserDirectoryPath() returns a "Request<string>" and I don't know how to get the string from that.

 

Please could anyone help?

 

Thanks

 

  • I think you need to use it like that:

    Platform.CloudStorage2.GetUserDirectoryPath().OnComplete(res=> {
    	if (res.IsError) {
    		Debug.LogError(res.GetError().Message);
    	} else {
    		Debug.LogError(res.GetString());
    	}
    });

    res.GetString() should contain path that you need, but I can't test it for sure, because I'm getting another error right now 😞

4 Replies

Replies have been turned off for this discussion
  • I think you need to use it like that:

    Platform.CloudStorage2.GetUserDirectoryPath().OnComplete(res=> {
    	if (res.IsError) {
    		Debug.LogError(res.GetError().Message);
    	} else {
    		Debug.LogError(res.GetString());
    	}
    });

    res.GetString() should contain path that you need, but I can't test it for sure, because I'm getting another error right now 😞

  • Thanks very much - that got GetUserDirectoryPath working for me (once I also allowed for its async nature).

     

    In case its ever helpful to anyone else, for me it returned "/storage/emulated/0/Android/data/com.MyCoolCompany.MyAwesomeGame/files/cloud/data".

     

    I've used that to now save my save data into what I think should be the correct place (and I can see it there using Explorer from my Windows development machine).  Unfortunately though, on the in-Oculus Apps display my app now always shows as "Syncing", and I don't see anything appear on the Cloud Storage page of the online Oculus Developer App Dashboard, which I was expecting to, so I think there must be something else I'm meant to do to get this working 😞

    • paultapper's avatar
      paultapper
      Explorer

      For the sake of posterity, I tried adding 

      <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

      to my AndroidManifet.xml but it still wasn't working.  Left it over night, and in the morning it had magically started working.  The App seems to sync ok in the Oculus Quest 2 UI, and in the Oculus Developer Dashboard I can see the files that should have been synced have. 🙂