Код: Выделить всё
#if UNITY_ANDROID
//private string _adUnitId = "ca-app-pub-3940256099942544/5354046379"; //test key
private string _adUnitId = "my-key";
#elif UNITY_IPHONE
private string _adUnitId = "test-key";
#else
private string _adUnitId = "unused";
#endif
private RewardedInterstitialAd _rewardedInterstitialAd;
void Start()
{
// Initialize the Google Mobile Ads SDK.
MobileAds.Initialize((InitializationStatus initStatus) =>
{
// This callback is called once the MobileAds SDK is initialized.
});
LoadRewardedInterstitialAd();
}
public void ShowRewardedInterstitialAd(string adsType)
{
if (_rewardedInterstitialAd != null && _rewardedInterstitialAd.CanShowAd())
{
_rewardedInterstitialAd.Show((Reward reward) =>
{
switch (adsType)
{
case "coin":
coinCount += 5;
PlayerPrefs.SetInt("coin", coinCount);
isClicked = true;
break;
case "level":
level += 1;
PlayerPrefs.SetInt("level", level);
SceneManager.LoadScene("GameScene");
break;
default:
Debug.Log("Hatalı Reklam Türü");
break;
}
});
}
}
Подробнее здесь: https://stackoverflow.com/questions/797 ... k-aab-mode
Мобильная версия