Sign In Register

How can we help you today?

Start a new topic
Answered

Virtual Good with image URL

Hello.


Is there any way to have an associated image URL to a virtual good?


Thanks.


Best Answer

Hey Jorge, what I'm doing is similar. I'm associating my gameObjects with virtual goods from the Platform. I'm not sure what host application (Unity, XCode...) you are using, but the way I did this in Unity is put my objects to a "Resources" folder (which can contain any type of asset really) and name them the same as shortCode.


This way when I fetch,  

using UnityEngine;
using System.Collections;

public class VirtualGood {

	public string description { get; set; }
	public string shortCode { get; set; }
	public int currency1Cost { get; set; }
	public string name { get; set; }
	public string resourcesPath { get { return this.shortCode; } }
}

public class MembershipManager : MonoBehaviour {
...
GameSparksApi.listVirtualGoodsRequest().sendAsync(onListVirtualGoodResult);
...

void onListVirtualGoodResult(IDictionary<string,object> response)
	{
                // Fetch virtualGoods from GameSparks
		Game.Instance.VirtualGoods = SimpleJson.SimpleJson.DeserializeObject<List<VirtualGood>>(response["virtualGoods"].ToString());

		// Get prefabs based on VirtualGoods.resourcesPath
		foreach(VirtualGood virtualGood in Game.Instance.VirtualGoods)
		{
			Game.Instance.WeaponPrefabs.Add(Resources.Load<Transform>(virtualGood.resourcesPath)); 
		}
	}
...
}

   I map the result to my virtualGoods list which I then use all over my game.


Hope this helps.


Answer

Hey Jorge, what I'm doing is similar. I'm associating my gameObjects with virtual goods from the Platform. I'm not sure what host application (Unity, XCode...) you are using, but the way I did this in Unity is put my objects to a "Resources" folder (which can contain any type of asset really) and name them the same as shortCode.


This way when I fetch,  

using UnityEngine;
using System.Collections;

public class VirtualGood {

	public string description { get; set; }
	public string shortCode { get; set; }
	public int currency1Cost { get; set; }
	public string name { get; set; }
	public string resourcesPath { get { return this.shortCode; } }
}

public class MembershipManager : MonoBehaviour {
...
GameSparksApi.listVirtualGoodsRequest().sendAsync(onListVirtualGoodResult);
...

void onListVirtualGoodResult(IDictionary<string,object> response)
	{
                // Fetch virtualGoods from GameSparks
		Game.Instance.VirtualGoods = SimpleJson.SimpleJson.DeserializeObject<List<VirtualGood>>(response["virtualGoods"].ToString());

		// Get prefabs based on VirtualGoods.resourcesPath
		foreach(VirtualGood virtualGood in Game.Instance.VirtualGoods)
		{
			Game.Instance.WeaponPrefabs.Add(Resources.Load<Transform>(virtualGood.resourcesPath)); 
		}
	}
...
}

   I map the result to my virtualGoods list which I then use all over my game.


Hope this helps.

Hi, Pavao.


I'm doing my app in AS3, and I'm approaching a solution very similar to yours.


Thanks for yoy answer and good luck with you app. :-)