Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Ad is shown only twice! Help!

Discussion in 'Unity Ads & User Acquisition' started by Vipatronon, Aug 23, 2016.

  1. Vipatronon

    Vipatronon

    Joined:
    Aug 23, 2016
    Posts:
    11
    Hi there!
    Well, I'm new to the unity ad, and i'm using the integrated version in unity 5.3
    In my app, there is a blanc scene with the Advertisement, and other with the application. Whenever the player loses, the app is restarted by my Ad scene.
    The problem is: when the player restart the app by the third time, the Ad is not being showed!
    My app is not in the player Store yet, here lies the problem?


    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.Advertisements;
    3. using UnityEngine.SceneManagement;
    4.  
    5. public class AdvertisementManagement : MonoBehaviour {
    6.     public bool showAds = true;
    7.     public float timeOut = 5f;
    8.  
    9.     private bool hasShownAd = false;
    10.  
    11.     void Awake () {
    12.         if (Advertisement.isSupported) {
    13.             Advertisement.Initialize ("1115287", false);
    14.         }
    15.     }
    16.  
    17.     void Start () {
    18.         OnLevelWasLoaded (0);
    19.     }  
    20.  
    21.     public void Update () {
    22.         ShowAd ();
    23.     }
    24.  
    25.     public void ShowAd () {
    26.         if (showAds) {
    27.             if (!hasShownAd) {
    28.                 if (!Advertisement.IsReady ()) {
    29.                     timeOut -= Time.deltaTime;
    30.                     if (timeOut <= 0) {
    31.                         //hasShownAd = true;
    32.                         Application.Quit ();
    33.                     }
    34.                 }
    35.  
    36.                 else {
    37.                     var options = new ShowOptions { resultCallback = HandleShowResult };
    38.                     Advertisement.Show (null, options);
    39.                     hasShownAd = true;
    40.                 }
    41.             }
    42.  
    43.             else {
    44.                 SceneManager.LoadScene ("Application");
    45.             }
    46.         }
    47.     }
    48.  
    49.     void OnLevelWasLoaded (int level) {
    50.         if (level == 0)
    51.             ShowAd ();
    52.     }
    53.  
    54.     private void HandleShowResult (ShowResult result) {
    55.         switch (result) {
    56.             case ShowResult.Finished:
    57.                 SceneManager.LoadScene ("Application");
    58.                 break;
    59.  
    60.             case ShowResult.Skipped:
    61.                 SceneManager.LoadScene ("Application");
    62.                 break;
    63.  
    64.             case ShowResult.Failed:
    65.                 Application.Quit ();
    66.                 break;
    67.         }
    68.     }
    69. }
    Thanks for any kind of help!
     
  2. STEFZIV

    STEFZIV

    Joined:
    May 9, 2014
    Posts:
    9
    Amount of ad that you can show is limited. What are you using: Rewarded videos or not rewarded videos?
     
  3. Vipatronon

    Vipatronon

    Joined:
    Aug 23, 2016
    Posts:
    11
    I think I'm using the default when you first start to use Unity Ad.

    Name: Video, Integration ID: video, Allow Skip: after 5 seconds, mute audio: no, Enable: true, Default true
     
  4. STEFZIV

    STEFZIV

    Joined:
    May 9, 2014
    Posts:
    9
    Wait when player loses, you reset the game? Not scene?
     
  5. Vipatronon

    Vipatronon

    Joined:
    Aug 23, 2016
    Posts:
    11
    I load again the Ad Scene
     
  6. Vipatronon

    Vipatronon

    Joined:
    Aug 23, 2016
    Posts:
    11
    I solved my problem...
    In this forum http://unityads.unity3d.com/help/faq/monetization, there are a question "Why am I only seeing 2 or 3 ads at a time?".

    I figured out that I understood wrong the "Add Filtering" tab, and I was blocking almost everything.

    Solved
     
    mikaisomaa likes this.
  7. STEFZIV

    STEFZIV

    Joined:
    May 9, 2014
    Posts:
    9
    Nice