GSData myGSData = message.Data.GetGSData("name of GSData key");
But how is this set in cloud code?
Please explain what you know in detail, do not try to simplify. I'd like this forum to become a reference for saving all variable types to a scriptMessage and retrieving and applying the data in Unity. Multiple implementation examples are appreciated.
Best Answer
C
Customer Support
said
over 6 years ago
Hi Ian,
The 'Get' function used to retrieve your data in Unity is dependant on the type of data you add to the message's script data.
So, if you were to add an object to the script data, it would be retrieved by using GetGSData. For example:
If you have any more questions please let us know.
Regards,
Vinnie
I
Ian Robinson
said
over 6 years ago
Excellent, thank you Vinnie! This is how I thought it would work, I thought I tried this and it threw an error but there could have been another variable messing things up at that time. Ill try this again and let you know how it goes!
Is it possible to save the entire challenge object to the ScriptMessage?
Thanks,
Ian
Customer Support
said
over 6 years ago
Hi Ian,
Yes, this is possible provided your cloud code has access to id of the challenge you wish to send. It can be done as follows:
var chall = Spark.getChallenge(challengeId);
Spark.setScriptData("myChallenge", chall);
This, again, would be retrieved on the client end using 'GetGSData("myChallenge")'
Vinnie
I
Ian Robinson
said
over 6 years ago
That simple? I could have sworn I tried this. Ill try again.
Ian Robinson
Hi. I'd like this forum to cover saving all variable types to a Spark.message().setMessageData() in cloud code and retrieving them in unity.
First i'll explain what I know. I know how to set up the message in messages tab:
Next you will need to set up the listener in Unity:
I'd really like to be able to access the challenge from my scriptMessage like I do from the built in challengeMessages.
So far I only know how to set individual strings and ints and interpret them in unity using C#.
And then retrieve it in unity using:
But how do I save a retrieve GSData, ScriptData, JSONData, an entire Challenge object?
and:
I know of:
But how is this set in cloud code?
Please explain what you know in detail, do not try to simplify. I'd like this forum to become a reference for saving all variable types to a scriptMessage and retrieving and applying the data in Unity. Multiple implementation examples are appreciated.
Hi Ian,
The 'Get' function used to retrieve your data in Unity is dependant on the type of data you add to the message's script data.
So, if you were to add an object to the script data, it would be retrieved by using GetGSData. For example:
then this data would be retrieved using:
If you have any more questions please let us know.
Regards,
Vinnie
- Oldest First
- Popular
- Newest First
Sorted by Oldest FirstCustomer Support
Hi Ian,
The 'Get' function used to retrieve your data in Unity is dependant on the type of data you add to the message's script data.
So, if you were to add an object to the script data, it would be retrieved by using GetGSData. For example:
then this data would be retrieved using:
If you have any more questions please let us know.
Regards,
Vinnie
Ian Robinson
Excellent, thank you Vinnie! This is how I thought it would work, I thought I tried this and it threw an error but there could have been another variable messing things up at that time. Ill try this again and let you know how it goes!
Is it possible to save the entire challenge object to the ScriptMessage?
Thanks,
Ian
Customer Support
Hi Ian,
Yes, this is possible provided your cloud code has access to id of the challenge you wish to send. It can be done as follows:
var chall = Spark.getChallenge(challengeId);
Spark.setScriptData("myChallenge", chall);
This, again, would be retrieved on the client end using 'GetGSData("myChallenge")'
Vinnie
Ian Robinson
That simple? I could have sworn I tried this. Ill try again.
Thank you Vinnie!!!
Ian
-
Documentation Notes
-
Design issues with user events
-
Using NoSQL
-
Runtime Collections vs Metadata Collections
-
Anonymous authentication from browser app
-
Modules
-
Movement With Unity
-
Problem with url parameters for downloadables
-
Querying NoSql GameSparks database
-
Challenge accesType
See all 2487 topics