Search Unity

Unity Ads constantly playing - Just looking to play one ad on game start

Discussion in 'Unity Ads & User Acquisition' started by ekimjune23, Aug 13, 2015.

  1. ekimjune23

    ekimjune23

    Joined:
    Jul 27, 2015
    Posts:
    1
    Hi,

    I'm looking for help getting Unity Ads to play one ad when my game (Android app) starts, then stop playing ads.

    Right now the ads constantly play, one after the other. Getting the ads to work was a small victory, as I'm new to Unity and programming, but it makes the game unplayable. I'm trying to keep things simple, by just having one ad so I don't have to worry about interrupting game play later on.

    It's probably an easy fix for someone who knows what they're doing. Below is the script I found that works for my game with the Unity Ads plugin from the asset store (I tried many ad services/methods). If it can be modified to achieve what I'm looking for, I'd appreciate it.

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using UnityEngine.Advertisements;
    4.  
    5. public class SimpleAds : MonoBehaviour
    6. {
    7.     void Start ()
    8.     {
    9.         Advertisement.Initialize ("59257");
    10.  
    11.         StartCoroutine (ShowAdWhenReady());
    12.     }
    13.  
    14.     IEnumerator ShowAdWhenReady()
    15.     {
    16.         while (!Advertisement.IsReady ())
    17.             yield return null;
    18.  
    19.         Advertisement.Show ();
    20.     }