1. We've introduced thread tags, search within a thread and similar thread search. Read more here.
    Dismiss Notice
  2. Learn how you'll soon be able to publish your games to China in four simple steps with Xiaomi. Sign up now for early access.
    Dismiss Notice
  3. Get further faster with the Unity Plus Accelerator Pack, free for new Unity Plus subscribers for a limited time. Click here for more details.
    Dismiss Notice
  4. We've released our first Timeline Experimental Preview, our new tool for creating cutscenes and more! To check it out click here.
    Dismiss Notice
  5. Unity 5.5 is now released.
    Dismiss Notice
  6. Check out all the fixes for 5.5 in patch releases 1 & 2.
    Dismiss Notice
  7. Unity 5.6 beta is now available for download.
    Dismiss Notice

My rewarded video ads are not showing

Discussion in 'Unity Ads' started by witcher101, Mar 20, 2017.

  1. witcher101

    witcher101

    Joined:
    Sep 9, 2015
    Posts:
    167
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using UnityEngine.UI;
    4. using UnityEngine.Advertisements;
    5.  
    6. public class UnityAdsButton : MonoBehaviour {
    7.     public string zoneId;
    8.     Button m_Button;
    9.     // Use this for initialization
    10.     void Awake()
    11.     {
    12.         Advertisement.Initialize(zoneId, false);
    13.     }
    14.  
    15.     void Start() {
    16.  
    17.         m_Button = GetComponent<Button>();
    18.         if (m_Button) m_Button.onClick.AddListener(ShowAdPlacement);
    19.  
    20.         StartCoroutine(ShowAdWhenReady());
    21.     }
    22.     IEnumerator ShowAdWhenReady()
    23.     {
    24.         while (!Advertisement.IsReady())
    25.             yield return null;
    26.  
    27.         Advertisement.Show();
    28.     }
    29.     // Update is called once per frame
    30.     void Update()
    31.     {
    32.         if (m_Button)
    33.         {
    34.             if (string.IsNullOrEmpty(zoneId)) zoneId = null;
    35.             m_Button.interactable = Advertisement.IsReady(zoneId);
    36.         }
    37.     }
    38.     void ShowAdPlacement()
    39.     {
    40.         if (string.IsNullOrEmpty(zoneId)) zoneId = null;
    41.         var options = new ShowOptions();
    42.         options.resultCallback = HandleShowResult;
    43.         Advertisement.Show(zoneId, options);
    44.     }
    45.  
    46.     void HandleShowResult(ShowResult result)
    47.     {
    48.         switch (result)
    49.         {
    50.             case ShowResult.Finished:
    51.                 Debug.Log("Video completed. Offer a reward to the player.");
    52.                 break;
    53.             case ShowResult.Skipped:
    54.                 Debug.LogWarning("Video was skipped.");
    55.                 break;
    56.             case ShowResult.Failed:
    57.                 Debug.LogError("Video failed to show.");
    58.                 break;
    59.         }
    60.         if (result == ShowResult.Finished)
    61.         {
    62.             m_Button.interactable = false;
    63.             MainGameController.totalMoneyMade *= 2;
    64.  
    65.         }
    66.     }
    67. }
    68.  
    I am trying to show rewarded videos, it doesnt show up. I used test ads 1st. 1 ad is shown at start of game.
    But rewarded video button remains uninteractable. Then i put test ads to false and still no ads are shown not even the 1st ad when game starts. What am i doing wrong??
     
  2. rasmus-unity

    rasmus-unity

    Unity Technologies

    Joined:
    Aug 15, 2014
    Posts:
    702
    "Advertisement.Initialize(zoneId, false);"

    You should initialize with a game id, not zone id.
     
  3. witcher101

    witcher101

    Joined:
    Sep 9, 2015
    Posts:
    167
    ya i am initialising with gameid from unity dashbaord.
    its just named zoneid in code
     
  4. rasmus-unity

    rasmus-unity

    Unity Technologies

    Joined:
    Aug 15, 2014
    Posts:
    702
    But later in your code, you also use zoneId for Show() method. Concepts:

    Game id: The integer number, which you get from dashboard, e.g. 1000000. This is used for Initialize() call
    Placement id: The "placement" in your game, which can be configured from dashboard. Default placements are typically "video" and "rewardedVideo". This is used for IsReady() and Show() calls

    Seems you have copied most of your code from https://unity3d.com/services/ads/quick-start-guide. But you should make sure to distinguish between gameId and placementId/zoneId.

    /Rasmus