Search Unity

why isn't my ad screen appearing?

Discussion in 'Unity Ads & User Acquisition' started by isanvel, Dec 30, 2019.

  1. isanvel

    isanvel

    Joined:
    Mar 21, 2019
    Posts:
    41
    i get the debug.log printed to console but it isn't showing anything on screen

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.Advertisements;
    5.  
    6. public class AdsController : MonoBehaviour
    7. {
    8.     string playstoreID = "3403842";
    9.     string videoAd = "video";
    10.     bool testMode = true;
    11.  
    12.     [SerializeField] LivesManager deathCounter;
    13.  
    14.     // Start is called before the first frame update
    15.     void Start()
    16.     {
    17.         deathCounter = FindObjectOfType<LivesManager>();
    18.         Advertisement.Initialize(playstoreID, testMode);
    19.     }
    20.  
    21.     // Update is called once per frame
    22.     void Update()
    23.     {
    24.        InitializeMonetization();
    25.     }
    26.  
    27.     public void InitializeMonetization()
    28.     {
    29.         if (deathCounter.deathCounter == 3)
    30.         {          
    31.             PlayAd();
    32.         }
    33.     }
    34.  
    35.     public void PlayAd()
    36.     {      
    37.             Debug.Log("ad");
    38.             Advertisement.Show("video");
    39.             deathCounter.deathCounter = 0;
    40.     }
    41. }
    42.  
     
    DMac360 likes this.
  2. ap-unity

    ap-unity

    Unity Technologies

    Joined:
    Aug 3, 2016
    Posts:
    1,519
    @isanvel

    Firstly, I would not call InitializeMonetization() in Update.

    You also need to check if an ad is ready before it will be shown using Advertisement.IsReady(videoAd).