Search Unity

  1. Check out the Unite LA keynote for updates on the Visual Effect Editor, the FPS Sample, ECS, Unity for Film and more! Watch it now!
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    Dismiss Notice
  4. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  5. 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.

  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. }