I’ve set up the Shop page in my game to show localized prices depending on the user’s location within my buttons’ text fields. It works fine (as far as I know) in the editor, and displays $0.01 (default for the editor as far as I’m aware).
However, whenever I upload the app to my Play Console and run it on my Android device, I get the generic Null Reference error for whenever something’s empty, despite having my In-App products set up. As a result, it just shows the default text I have set on my buttons.
Am I missing something in my script? Or is there something else I need to do in my Play Console that I’m not aware of (I’ve uploaded screenshots of how my In-App products are set up in the console)?
This is my script for the shop (as pertains to the localized price display):
void Awake()
{
removedAds = removeAdsTxt.GetComponent<Text>(); //Access the Remove Ads text
unlockedLvls = unlockLvlsTxt.GetComponent<Text>(); //Access the Unlock Levels text
unlockedSpecials = unlockSpecialsTxt.GetComponent<Text>(); //Access the Unlock Specials text
SetUpBuilder(); //Activate the product builder
removedAds.text = "BUY - " + ReturnLocalizedPrice(noAdsItem.id); //Show the localized price on the Remove Ads button
unlockedLvls.text = "BUY - " + ReturnLocalizedPrice(unlockLevelsItem.id); //Show the localized price on the Unlock Levels button
unlockedSpecials.text = "BUY - " + ReturnLocalizedPrice(unlockSpecialsItem.id); //Show the localized price on the Unlock Specials button
}
public string ReturnLocalizedPrice(string id)// Product id
{
Product p = m_StoreController.products.WithID(id);
decimal price = p.metadata.localizedPrice;
string code = p.metadata.isoCurrencyCode;
return price + " " + code;
}