Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

unity ads 2.0 not start on first scene load

Discussion in 'Unity Ads & User Acquisition' started by dianadorinamita, May 2, 2018.

  1. dianadorinamita

    dianadorinamita

    Joined:
    Jan 21, 2016
    Posts:
    25
    unity ads not load on first scene, if i load second scene and back to first scene will show ads
    - on old version plugin ads 1.5 the ads will show on first scene after few seconds, please help


    Code (CSharp):
    1. using UnityEngine;
    2. #if UNITY_ANDROID
    3.     using UnityEngine.Advertisements;
    4. #endif
    5.  
    6. public class UnityAdsInitializer : MonoBehaviour
    7. {
    8.     [SerializeField]
    9.     private string
    10.     androidGameId = "1443906",
    11.     iosGameId = "1443906";
    12.  
    13.     [SerializeField]
    14.     private bool testMode;
    15.     bool off_Ads = false;
    16.     string gameId;
    17.     void Start ()
    18.     {
    19.         gameId = null;
    20.  
    21.         #if UNITY_ANDROID
    22.             gameId = androidGameId;
    23.         Advertisement.Initialize(androidGameId,testMode);
    24.         #elif UNITY_IOS
    25.             gameId = iosGameId;
    26.         #endif
    27.  
    28.         //if (Advertisement.isSupported && !Advertisement.isInitialized) {
    29.         //    Advertisement.Initialize(gameId, testMode);
    30.         //
    31.         InvokeRepeating("Init_Ads",0f,6f);
    32.         Invoke ("ShowAds", 5f);
    33.         Showads ();
    34.     }
    35.  
    36.     void Init_Ads()
    37.     {
    38.         #if UNITY_ANDROID || UNITY_IOS
    39.             Advertisement.Initialize(gameId, testMode);
    40.             //print ("Ads Shown");
    41.         #endif
    42.     }
    43.  
    44.     void Showads()
    45.     {
    46.         #if UNITY_ANDROID || UNITY_IOS
    47.             Advertisement.Show ();
    48.             //print ("Ads Shown
    49.         #endif
    50.     }
    51.      
    52. }
     
  2. rasmus-unity

    rasmus-unity

    Unity Technologies

    Joined:
    Aug 15, 2014
    Posts:
    1,312
    Why initialize multiple times, i.e. call to
    Code (CSharp):
    1. InvokeRepeating("Init_Ads",0f,6f);
    ?

    SDK 2.0 does make an extra request to server, so might be in your case that it doesn't finish within 5 seconds, before you call "ShowAds" method? (Although usually it should be ready before 5 seconds)

    /Rasmus
     
  3. dianadorinamita

    dianadorinamita

    Joined:
    Jan 21, 2016
    Posts:
    25
    please edit my script and send me back, im not programmer , y pay someone to made this
     
  4. rasmus-unity

    rasmus-unity

    Unity Technologies

    Joined:
    Aug 15, 2014
    Posts:
    1,312