I am using a basic ad script that I will provide below and, after upgrading to Unity 2022 so that I had the right android API level I now have problems with ads. Any and all ad scripts have errors that are not actual errors. I have the Advertisements Legacy and now an Advertisements Mediation package. Neither seem to help and it does not matter which one is attached, I still have these errors. Can you tell me how I can use the same basic ad script in my 2022 project?
public class BannerAdScript : MonoBehaviour
{
public string gameId = "1234567";
public string placementId = "bannerPlacement";
public bool testMode = true;
[SerializeField] BannerPosition _bannerPosition = BannerPosition.BOTTOM_CENTER;
void Start()
{
// Initialize the SDK if you haven't already done so:
Advertisement.Initialize(gameId, testMode);
StartCoroutine(ShowBannerWhenReady());
// Set the banner position:
Advertisement.Banner.SetPosition(_bannerPosition);
}
IEnumerator ShowBannerWhenReady()
{
while (!Advertisement.IsReady(placementId))
{
yield return new WaitForSeconds(0.5f);
}
Advertisement.Banner.Show(placementId);
}
}
↧