question

Anatoly Volnov avatar image
Anatoly Volnov asked

Entity files docs sample doesn't compile and other docs gripes

Trying to get file uploads working, and the code sample on https://docs.microsoft.com/en-us/gaming/playfab/features/data/playerdata/entity-files does not compile for me in Unity 2019.2.6f1, complaining that it "cannot convert from 'method group' to 'Action<byte[]>'" on arg 3 of SimplePutCall in OnInitFileUpload, so that's the FinalizeUpload method in the sample. I'm attaching a screenshot of the place in the code.

screenshot-2019-12-02-at-183905.jpg

Also overall I find that the entity docs feel really undercooked without enough samples, the code language selection on the old docs platform doesn't function, it's stuck on Unity C# (So I can't look at syntax samples on how to deal with entities in CloudScript, for example, so I never got that to work, never figured out how to simply GetObjects from CloudScript). The github samples aren't that much help either. Having to scrounge the forums just for some samples is not a very good experience. Have I missed something or is it really like this?

Something like a sample Unity project (that has entities and isn't 3 years old) that just has most of the things in the SDK implemented and CloudScript entity samples would go miles towards aiding in understanding the platform for someone like me who's a jack of all trades solo developer and not a professional programmer by trade. Working with stats, leaderboards, and player data is really easy by comparison, for example, just because there are samples for most of what you'd want to do with them.

entitiesdocumentation
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

·
Sarah Zhang avatar image
Sarah Zhang answered

We will try to inform our team about this documentation issue about the sample code doesn't suit the latest SDK. Currently, you can modify the code to the following one.

PlayFabHttp.SimplePutCall(response.UploadDetails[0].UploadUrl, 
payload,
//FinalizeUpload, 
success => { FinalizeUpload(); }, 
error => { Debug.Log(error); } 
);

About the Entity examples on CloudScript, you can find a SetObject sample in the first(default) CloudScript revision, on the line 78 handlers.makeEntityAPICall, it also contains some information in the comments, you can refer to it to call GetObject and other Entity API.

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

Anatoly Volnov avatar image Anatoly Volnov commented ·

Thank you for the response and the clarification, that does compile now.

What's not clear to me in regards to GetObject is not the call itself necessarily, but how to treat the result in CloudScript. This may be just an issue of me not being too familiar with JS and its dynamic typing, but I'd still appreciate at least one example somewhere of getting an actual value out of an object in CloudScript.

0 Likes 0 ·
Sarah Zhang avatar image Sarah Zhang Anatoly Volnov commented ·

Have you checked this doc Writing custom CloudScript for a tutorial and a simple sample of CloudScript? The methods of treating results are similar.

0 Likes 0 ·
Sarah Zhang avatar image Sarah Zhang Sarah Zhang commented ·

>> Could you please point me in the right direction?

You can refer to the above content to modify the field name in the second last line. The field's name that you write after dot or in the brackets should have the same content and structure as the response of GetObjects. You can test PlayFab API using external REST API testing tools (like Postman) and check the responses before you call them on CloudScript. Or you can also check the API references to confirm the correct field name.

>> Are segment and other actions supported by the entity system?

No, Segment is targeted for players, not entities. PlayFabId is the entity Id of master_player_account, but Segment operation is targeted for players, you can convert entity Id of master_player_account to playfabId to get a player's segment via API GetPlayerSegments but they have no other relevances.

2 Likes 2 ·
Show more comments
Show more comments

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.