Search Unity

  1. Get all the Unite Berlin 2018 news on the blog.
    Dismiss Notice
  2. Unity 2018.2 has arrived! Read about it here.
    Dismiss Notice
  3. Improve your Unity skills with a certified instructor in a private, interactive classroom. Learn more.
    Dismiss Notice
  4. ARCore is out of developer preview! Read about it here.
    Dismiss Notice
  5. Magic Leap’s Lumin SDK Technical Preview for Unity lets you get started creating content for Magic Leap One™. Find more information on our blog!
    Dismiss Notice
  6. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

C# script for unity ads

Discussion in 'Scripting' started by street9605, Jul 14, 2018 at 12:32 AM.

  1. street9605

    street9605

    Joined:
    Jun 14, 2018
    Posts:
    5
    Hello!
    So my unity ads are all set up. In the unity simulator everything is working ("Everything seems to be working"). But now, my app is on the AppStore and there is no ads showing.
    Anyone who knows whats the problem ? Is it in my code? please help


    My code:

    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.Advertisements;
    3.  
    4. public class Ads : MonoBehaviour
    5. {
    6.  
    7.  
    8.  
    9.     static int loadCount = 0;
    10.  
    11.     void Start()
    12.     {
    13.         if (loadCount % 3 == 0)  // only show ad every third time
    14.         {
    15.             ShowAd();
    16.         }
    17.         loadCount++;
    18.     }
    19.  
    20.     public void ShowAd()
    21.     {
    22.         if (Advertisement.IsReady("video"))
    23.         {
    24.             Advertisement.Show("video");
    25.         }
    26.     }
    27. }