Search Unity

Advertisement.Initialize() is counting as an Ad Request?

Discussion in 'Unity Ads & User Acquisition' started by BoneCrackerGames, Apr 22, 2015.

  1. BoneCrackerGames

    BoneCrackerGames

    Joined:
    Feb 4, 2014
    Posts:
    17
    Hi,

    I'm initializing the Unity Ads at each start of the level. And if player plays 10 times on any scene, a video ad is showing up. Works great. But i got weird results;

    I got 300 Ad requests,
    Videos Started = 19,

    Should I initialize Unity Ads only if player hits 10 times of playcount?

    Thanks,
    Bugra
     
  2. unity-nikkolai

    unity-nikkolai

    Joined:
    Sep 18, 2014
    Posts:
    540
    You should only initialize Unity Ads once in your game.

    You can check if Unity Ads is already enabled before attempting to enable again:
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using UnityEngine.Advertisements;
    4.  
    5. public class UnityAdsInitExample : MonoBehaviour
    6. {
    7.     public string gameID;
    8.     public bool enableTestMode;
    9.  
    10.     void Start ()
    11.     {
    12.         if (string.IsNullOrEmpty(gameID))
    13.         {
    14.             Debug.LogError("Unable to initialize Unity Ads without a valid Game ID.");
    15.         }
    16.         if (Advertisement.isInitialized)
    17.         {
    18.             Debug.LogWarning("Unity Ads is already initialized.");
    19.         }
    20.         else
    21.         {
    22.             Debug.Log(string.Format("Initializing Unity Ads for game ID {0} with test mode {1}.",
    23.                                     gameID, enableTestMode ? "enabled" : "disabled"));
    24.      
    25.             Advertisement.Initialize(gameID,enableTestMode);
    26.         }
    27.     }
    28. }