Hi,
how to design a “remove ads” option in android unity game?
I have been searching but cannot see any sample code, does anyone have any advise on how to do this?
Thanks,
Kim
Hi,
how to design a “remove ads” option in android unity game?
I have been searching but cannot see any sample code, does anyone have any advise on how to do this?
Thanks,
Kim
I did it in my game simple by using playerprefs. If player buys/uses “remove ads”-option, save it in playerprefs and destroy all ad-objects and events. Every time you start the game, check if player has the adfree version and if player has then don’t setup ads.
function Awake()
{
SetupAds();
}
function SetupAds()
{
if(PlayerPrefs.HasKey("AdFree"))
return;
// Setup your ads here
}
function RemoveAds()
{
if (PlayerPrefs.HasKey("AdFree"))
print("Ads already removed");
else{
PlayerPrefs.SetInt("AdFree", 1);
PlayerPrefs.Save();
// destroy/disable all your ad objects here
}
}
function RestorePurchases()
{
if (IsProductPurchased("ProductId"))
RemoveAds();
}