我试图使用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
}
这是我将应用构建到Google Play并运行应用时的价格。
我错过了一步吗?
答案 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;
}
感谢大家的帮助!