Sign In Register

How can we help you today?

Start a new topic

how get custom currency from response in unity ?

All the time ive got a problem with custom currency addes like in tutorial but i cant get that value from normal unity response (like currency1) : 

  new GameSparks.Api.Requests.AccountDetailsRequest().Send((response) => {

   if (!response.HasErrors) {

    Debug.Log("Account Details Found...");

playerName = response.DisplayName;

playerGold = response. ????????

    int cashAvailable = (int) response.Currency1;

There is any way to get that custom currnecy from response ?

i found  there :

but i cant get responce.Currencies in newest version of Gamesparks SDK for  untiy 

I'm getting the same error that response.Currencies doesn't exist. So the example is broken.

The same here. Looks like class AccountDetailsResponse no more has property JSON Currencies.
I've lost two days trying to figure out the problem.

Guys, please rework your tutorials or change the code. 

(6.19 KB)

Thats how currencies used to work 4 days ago, they recently changed how currencies are defined.

"Feature --- You can now create and configure custom currencies for your games as configurable objects, which can be referenced programmatically using their Short Code. 12939"

For more information about currencies check this out:

"Existing Games and New Games? For existing games, you can add new currencies to supplement the currencies you’ve enabled in Game Edit. For new games, you must create all of the currencies you need."

Hi Guys, 

This hasn't been added to the Unity SDK yet but you can get it from the AccountDetailsRequests response with the following. Example below is for a currency with the shortCode "customCurrency".

int? customCurrency = response.BaseData.GetGSData("currencies").GetInt("customCurrency");


When the SDK has been updated you'll be able to do this with the method defined here.



I seem to be having trouble accessing the value of my custom currency using your code example:


I've tried a few variations but it always comes back null. And in fact, if I remove the last bit with my custom currency and just try to access:


It's still coming back null.

I guess I'm confused about the differences between custom currencies and default currencies. Since my game only has one currency throughout, is it possible to access .currency1 in my C# code and still get "CURRENCY_GEM" value, or must I always access this in my C# code using the string?



You can return custom currency in Cloud Code:


var req = new SparkRequests.AccountDetailsRequest();

var response = req.Send();

var currencies = response.currencies;

var GEMS = currencies["CURRENCY_GEM"];

Login to post a comment