如何从Unity AIP中获取AdMob的价格?

时间:2016-12-24 03:11:59

标签: unity3d admob

我试图使用Unity Ads和AdMob提高In App Purchase(IAP)的价格。

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

这是我将应用构建到Google Play并运行应用时的价格。 enter image description here

假设是1.99美元。 enter image description here

我错过了一步吗?

1 个答案:

答案 0 :(得分:4)

我终于找到了解决方案

需要调用代码OnInitialized

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

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

感谢大家的帮助!