- Home /
How Do I Implement Unity Ads 4.0, At previous I have 3.7.5.
Below Are the Code Of Unity Ads 3.7.5 I want to Convert It Into Unity Ads 4.0 it would really really help me and others noob like me a lot,,,,
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Advertisements;
public class UnityAdManager : MonoBehaviour { // Start is called before the first frame update void Start() { if (PlayerPrefs.HasKey("ads") == false) { Advertisement.Initialize("4481835"); } ShowBanner(); }
public void PlayAd()
{
if (Advertisement.IsReady("Interstitial_Android"))
{
Advertisement.Show("Interstitial_Android");
}
}
public void ShowBanner()
{
if (Advertisement.IsReady("Banner_Android"))
{
Advertisement.Banner.SetPosition(BannerPosition.BOTTOM_CENTER);
Advertisement.Banner.Show("Banner_Android");
}
else
{
StartCoroutine(RepeatShowBanner());
}
}
public void HideBanner()
{
Advertisement.Banner.Hide();
}
IEnumerator RepeatShowBanner()
{
yield return new WaitForSeconds(1);
ShowBanner();
}
}
Comment