Search Unity

  1. Unity 2019.1 beta is now available.
    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. We're looking for insight from anyone who has experience with game testing to help us better Unity. Take our survey here. If chosen to participate you'll be entered into a sweepstake to win an Amazon gift card.
    Dismiss Notice
  4. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  5. Unity 2018.3 is now released.
    Dismiss Notice
  6. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice

How to put ads in your game

Discussion in 'Unity Ads' started by cgcrockett, Feb 4, 2019.

  1. cgcrockett

    cgcrockett

    Joined:
    Sep 11, 2018
    Posts:
    2
    Hello,
    I'm sorry for posting this, since there is, probably a lot of these posts, but I haven't been able to find one that helps. I am using a simple code to implement ads in my game, but its not working.

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.SceneManagement;
    5. using UnityEngine.Advertisements;
    6.  
    7. public class LevelMenu : MonoBehaviour
    8. {
    9.     public void Menu()
    10.     {
    11.         SceneManager.LoadScene("Menu");
    12.     }
    13.  
    14.     public void DisplayAd()
    15.     {
    16.         if (Advertisement.IsReady())
    17.         {
    18.             Advertisement.Show();
    19.         }
    20.     }
    21. }
    22.  
    I have ads enabled in the editor and I have test mode on. The two functions in the code both connect to a button. When I press the button, no ads show up, so I'm wondering why. I've tried to display the ad by just pressing "K" to see if it was a problem with the button, but it still didn't work...

    [EDIT] I got it working. I needed to switch the platform to Android.
     
    Last edited: Feb 5, 2019