Search Unity

Unity Ads dont show up

Discussion in 'Unity Ads' started by Xazerek, May 19, 2015.

  1. Xazerek

    Xazerek

    Joined:
    Nov 3, 2014
    Posts:
    134
    Is it something wrong with this script?
    I dont have ad in game ;/
    Code (csharp):
    1.  
    2. using UnityEngine;
    3. using UnityEngine.Advertisements;
    4. using System.Collections;
    5.  
    6. public class Ad : MonoBehaviour {
    7.  
    8.     void Awake () {
    9.         if (Advertisement.isSupported) {
    10.             Advertisement.allowPrecache = true;
    11.             Advertisement.Initialize ("40030", false);
    12.             }
    13.     }
    14.    
    15.     void Start () {
    16.             Advertisement.Show(null, new ShowOptions {
    17.                 pause = true,
    18.                 resultCallback = result => {
    19.                
    20.                 }
    21.                 });
    22.     }
    23.    
    24. }
    25.  
     
  2. Ostwind

    Ostwind

    Joined:
    Mar 22, 2011
    Posts:
    2,772
    Xazerek likes this.
  3. Rasmus Selsmark

    Rasmus Selsmark

    Joined:
    Mar 13, 2013
    Posts:
    120
  4. Xazerek

    Xazerek

    Joined:
    Nov 3, 2014
    Posts:
    134
  5. Rasmus Selsmark

    Rasmus Selsmark

    Joined:
    Mar 13, 2013
    Posts:
    120
    Something like:

    Code (CSharp):
    1. public void ShowAd(string zoneId = null)
    2. {
    3.     if (!Advertisement.isReady(zoneId))
    4.     {
    5.         if (zoneId != null)
    6.         {
    7.             Debug.Log(string.Format("Not ready (zone '{0}')!", zoneId));
    8.         }
    9.         else
    10.         {
    11.             Debug.Log("Not ready!");
    12.         }
    13.         return;
    14.     }
    15.  
    16.     var options = new ShowOptions
    17.     {
    18.         resultCallback = result => Debug.Log(string.Format("Result: {0}", result))
    19.     };
    20.  
    21.     Advertisement.Show(zoneId, options);
    22. }
    And then call this method e.g. on end of scene, when clicking some button etc.
     
  6. Xazerek

    Xazerek

    Joined:
    Nov 3, 2014
    Posts:
    134
    Using this code i will earn money?
    How much $$$ for 1 view?
    Code (csharp):
    1.  
    2. using UnityEngine;
    3. using UnityEngine.Advertisements;
    4. using System.Collections;
    5.  
    6. public class SimpleAdScript : MonoBehaviour
    7. {
    8.  void Start ()
    9.  {
    10.  Advertisement.Initialize ("40030", true);
    11.  
    12.  StartCoroutine (ShowAdWhenReady ());
    13.  }
    14.  
    15.  IEnumerator ShowAdWhenReady()
    16.  {
    17.  while (!Advertisement.isReady ())
    18.  yield return null;
    19.  
    20.  Advertisement.Show ();
    21.  }
    22. }
    23.  
    How to add banner ads?
     
  7. Ostwind

    Ostwind

    Joined:
    Mar 22, 2011
    Posts:
    2,772