question

Never Rage Dungeons and Dragons avatar image
Never Rage Dungeons and Dragons asked

READ ONLY DATA -Where do I put it in Unity?

Where do I put this read only data script in Unity-so that only I can set up the send and recieve data and when the game is build, players are not able to unwrap my script and use it?...I tried opening the already made "PlayFabDataAPI" script in playfab sdk but that didn't work. Also knowing that there is an "insert playfab id" variable in the script I am a bit sure it has to be run with in Unity as the player login.

Can anyone help me by telling me where to put the read only code within unity, without getting error (red squiggly lines) under the PlayFabServerAPI?

THIS SCRIPT IS FROM (https://api.playfab.com/docs/tutorials/landing-players/using-player-data): publicvoidUpdateUserReadOnlyData(){ PlayFabServerAPI.UpdateUserReadOnlyData(newUpdateUserDataRequest(){ PlayFabId ="user PlayFabId here - obtained from any successful LoginResult", Data =newDictionary<string,string>(){ {"Father","Fred"},{"Mother","Alice"},{"Sister","Lucy"},{"Brother","Doug"}}, Permission = UserDataPermission.Public }, result => Debug.Log("Set read-only user data successful"), error =>{ Debug.Log("Got error updating read-only user data:"); Debug.Log(error.GenerateErrorReport());});}

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Turner avatar image
Turner answered

We recommend against using any Server APIs locally inside of your build due to the security risks. Alternatively, you can use CloudScript to safely make server API calls. It has full access to the server API, so you could call UpdateUserReadOnlyData via Cloud Script.

If you're new to CloudScript. You can view the Quickstart here.

And there's actually a page in the docs where they specifically use UpdateUserReadOnlyData with CloudScript here.

3 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Never Rage Dungeons and Dragons avatar image Never Rage Dungeons and Dragons commented ·

Hi, I found out how to update the playerreadonly data. I just dont know how I can get it into unity...For example, the player readonly data for DmgOutPut = 5; I want to be able to get this value instead of having the player post his own value through the ClientUpdateUserData. I want to use the ReadOnly Data at runtime to make sure the player is only using 5 as his dmg output...

How do I use the ReadOnlyData, apart from posting it through cloudscript.

0 Likes 0 ·
Citrus Yan avatar image Citrus Yan Never Rage Dungeons and Dragons commented ·

Client/GetUserReadOnlyData, which is PlayFabClientAPI.GetUserReadOnlyData in Unity SDK, can do that.

0 Likes 0 ·
Never Rage Dungeons and Dragons avatar image Never Rage Dungeons and Dragons Citrus Yan commented ·

thanks, im starting to understand now

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.