2014-09-01 70 views
1

我剛買了Prime31的「Google In App Billing Plugin for unity3d」。我不明白如何在我想開發的遊戲中使用它。如何使用Prime31 Google In App帳單插件

你能給我看一個代碼示例嗎?我知道我需要使用我的應用程序密鑰,但我不知道下一步該怎麼做。 如何使用此插件進行測試購買?

請儘可能多地幫忙,因爲我在這個問題上困擾了很長一段時間。

這是我的一些所謂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;   
} 
+1

請告訴我們你已經嘗試過了。這聽起來太像一個'爲我做功課',這個網站沒有介紹。 – Rudolfwm 2014-09-01 15:54:14

回答

2

我發現問題並解決它!

這條線缺少我的AndroidManifest.xml出於某種原因:

<activity android:name="com.prime31.GoogleIABProxyActivity"></activity> 

剛剛添加的行,我現在有應用程序內購買!

相關問題