Is there any way to have an associated image URL to a virtual good?
Thanks.
Best Answer
P
Pavao Ivancek
said
over 8 years ago
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.
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.
J
Jorge Aldao
said
over 8 years ago
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. :-)
Jorge Aldao
Hello.
Is there any way to have an associated image URL to a virtual good?
Thanks.
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,
I map the result to my virtualGoods list which I then use all over my game.
Hope this helps.
- Oldest First
- Popular
- Newest First
Sorted by Oldest FirstPavao Ivancek
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,
I map the result to my virtualGoods list which I then use all over my game.
Hope this helps.
Jorge Aldao
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. :-)
-
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