GameSparks API

Hello,

Does anyone else use GameSparks? I am trying to implement their API directly into my unity game. I tried posting on their Discussion board but i didn’t get any answers. This is the code i’m having trouble implementing and it doesn’t compile correctly in unity and i got it directly from their site. I was hoping someone could either answer this question or tell me a better cloud service to use with supper support.

You can see in my attachment that its red on (includeDisabled) (tags) and GSEnumerable.

using GameSparks.Core;
using GameSparks.Api;
using GameSparks.Api.Requests;
using GameSparks.Api.Responses;

new ListVirtualGoodsRequest ()
.SetIncludeDisabled (includeDisabled)
.SetTags (tags)
.Send ((response) => {

			GSData scriptData = response.ScriptData;
			GSEnumerable<var> virtualGoods = response.VirtualGoods;

		});

92240-listvirtualgoodsrequest.jpg

Hi @swampman860912

Sorry for the delay in responding to your question.

Firstly, have you defined “tags” which is of type string, and “includeDisabled” which of type bool?

If not you would be getting null references here as they are present in the example snippet for context, with the assumption made that you would define and pass them to the request yourself.

Lastly, when iterating the response.virtualgoods, there seems to be a typo in our documentation. Rather than setting “response.virtualGoods” to a GSEnumerable type you can reference and iterate the response using a callback, and iterate from there. You can see that in the code below.

public void OnListVirtualGoodsSuccess(GameSparks.Api.Responses.ListVirtualGoodsResponse._VirtualGood[] virtualGoods)

{
  foreach (var item in virtualGoods)
  {
 Debug.Log(item.Name);
  }
}

I will ensure this typo is resolved and I apologize for the inconvenience it caused.

If you have any further questions or issues, please do not hesitate to get in touch with the GameSparks Support Team via https://support.gamesparks.net/support/home we’d be happy to help in any way we can!