2016-12-24 20 views
5

我正在嘗試使用Unity Ads和AdMob爲應用內購買(IAP)提供價格。如何從Unity AIP中的AdMob獲得價格?

public void InitializePurchasing() 
{ 
    // If we have already connected to Purchasing ... 
    if (IsInitialized()) 
    { 
     // ... we are done here. 
     return; 
    } 
    var builder = ConfigurationBuilder.Instance(StandardPurchasingModule.Instance()); 

    builder.AddProduct(PRODUCT_REMOVE_ADS, ProductType.NonConsumable); 

    UnityPurchasing.Initialize(this, builder); 

    removeAdsPriceText.text = m_StoreController.products.WithID("removeads").metadata.localizedPrice.ToString(); // This should be the code to get the price 
} 

價格在編輯器中,當我點擊播放: enter image description here

這是價格,當我構建應用程序到谷歌Play和運行應用程序。 enter image description here

這是假設爲$ 1.99 enter image description here

我錯過了一步?

+1

這是我到目前爲止所。當我在巡視員中按下游戲時,價格降至0.01美元,但是當我將其構建到我的手機時,它不會改變。 。removeAdsText.text = m_StoreController.products.WithID( 「removeads」)metadata.localizedPrice.ToString(); –

+1

製作移除廣告的IAP的目標是? –

+1

我有兩個IAP移除廣告,另一個解鎖所有內容。 –

回答

4

我終於想通了,該解決方案

的代碼需要調用OnInitialized

public void OnInitialized(IStoreController controller, IExtensionProvider extensions) 
{ 
    m_StoreController = controller; 
    m_StoreExtensionProvider = extensions; 

    removeAdsPriceText.text = m_StoreController.products.WithID("removeads").metadata.localizedPriceString; 
} 

感謝大家的幫助!