Sign In Register

How can we help you today?

Start a new topic
Answered

ScriptData I don't get it! [Unity]

Hi,


I've implemented an upload of a file to GS and added via an event 2 script data variables. This seems likes working, this is my code in Unity


new LogEventRequest().SetEventKey("UploadSave")
 .SetEventAttribute("uploadid", message.BaseData.GetString("uploadId"))
 .SetEventAttribute("uploadtime""" + cur_time)
 .Send((response) => {
 if (response.HasErrors)
 {
 Debug.Log("Failed");
 }
 else
 {
 Debug.Log("Successful");
 }
 });


Now I want to read this ScriptData.

This is my cloud code:

Spark.setScriptData("UploadId", Spark.getPlayer().getScriptData("UploadId"));

Spark.setScriptData("UploadTime", Spark.getPlayer().getScriptData("UploadTime"));


And then I try do get this data:


new GameSparks.Api.Requests.LogChallengeEventRequest_GetUserData()
 .Send((responseuserdata) => {
 
 if (!responseuserdata.HasErrors) // check we dont have errors
 {
 //string data1 = responseuserdata.ScriptData.GetString("UploadId");
 //string data2 = responseuserdata.ScriptData.GetString("UploadTime");
 Debug.Log("Response Data: " + responseuserdata.ScriptData);
 } else {
 Debug.Log("Response Error: " + responseuserdata.Errors);
 }

 });


All I got is the Response Error:


GS: SEND:{"@class":".LogChallengeEventRequest","eventKey":"GetUserData","requestId":"636069780168047630_1"}


Response Error: GameSparks.Core.GSData


Any help would be awesome!


Cheers,

Armin


Best Answer

Hi Armin


In the code you provided you are calling a log challenge event but the code you have written is in a log event

If you change LogChallengeEventRequest_GetUserData to LogEventRequest_GetUserData you should get the correct response/

You can also use are test harness to test cloud code outside of the client like Unity.


Cheers

Katie




Answer

Hi Armin


In the code you provided you are calling a log challenge event but the code you have written is in a log event

If you change LogChallengeEventRequest_GetUserData to LogEventRequest_GetUserData you should get the correct response/

You can also use are test harness to test cloud code outside of the client like Unity.


Cheers

Katie




1 person likes this

Hi Katie,


that worked. Thanks a lot. Can you answer me another short question where I can find in the backend the uploaded files by the users?


Cheers,

Armin

Hi Armin,


You can view any data sent to the server through the NoSQL module located on the GameSparks dashboard. 

Just press the find tab and select the collection were you stored the file.


Does this answer your question?

- Tony.

Login to post a comment