我刚买了Prime31的“谷歌在应用程序中为Prime31付费插件”。我不知道如何在我想要开发的游戏中使用它。
你能给我举个代码示例吗?我知道我需要使用我的应用键,但我不知道下一步该做什么。如何用这个插件进行测试购买呢?
请你尽可能多地帮忙,因为我在这个问题上真的困了一段时间了。
这是我的一些名为MoneyTakerScript (继承自MonoBehaviour)的“购买制造者”对象:
void Start()
{
string key = "My App Key...";
GoogleIAB.init(key);
var skus = new string[] { "cl.48931", "tp.58932", "mmm.68393" };
GoogleIAB.queryInventory( skus );
TPS = GameObject.Find("TPBtn").GetComponent(typeof(TPScript)) as TPScript;
CLS = GameObject.Find("CLBtn").GetComponent(typeof(CLScript)) as CLScript;
MMM = GameObject.Find("MMBtn").GetComponent(typeof(MMMScript)) as MMMScript;
}
public void Purchase(string ProductId)
{
GoogleIAB.purchaseProduct(ProductId);
}
public void UseProduct(string ProductId)
{
if (ProductId.Contains("cl"))
{
CLS.MakeCL();
}
if (ProductId.Contains("tp"))
{
TPS.MakeTP();
}
if (ProductId.Contains("mmm"))
{
MMM.MakeMMM();
}
GoogleIAB.consumeProduct(ProductId);
}这是我的“购买列表”的一些目标代码:
void purchaseSucceededEvent(GooglePurchase purchase)
{
//Debug.Log( "purchaseSucceededEvent: " + purchase );
MoneyScript.UseProduct(purchase.productId);
}
void Start()
{
MoneyScript = GameObject.Find("MoneyTaker").GetComponent(typeof(MoneyTakerScript)) as
MoneyTakerScript;
}发布于 2014-09-01 21:03:11
我发现了问题并解决了!
由于某种原因,我的AndroidManifest.Xml中缺少了这一行:
<activity android:name="com.prime31.GoogleIABProxyActivity"></activity>刚刚添加了一行,现在我已经在应用程序购买!!
https://stackoverflow.com/questions/25609224
复制相似问题