cancel
Showing results for 
Search instead for 
Did you mean: 

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

paultapper
Explorer

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

 

1 ACCEPTED SOLUTION

Accepted Solutions

sSvvSs
Protege

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 😞

View solution in original post

3 REPLIES 3

sSvvSs
Protege

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 😞

paultapper
Explorer

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 😞

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. 🙂