Search Unity

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