Search Unity

Can't make ads work

Discussion in 'Unity Ads & User Acquisition' started by PunisherXA, Nov 20, 2016.

  1. PunisherXA

    PunisherXA

    Joined:
    Jan 29, 2016
    Posts:
    11
    Hi.
    I'm developing a new game with ads, but I can't find what can I do for make it works, at least the example screen.
    I tried simple things like this, but I cant make it work.
    Code (CSharp):
    1. public void ShowDefaultAd()
    2.  
    3. using UnityEngine;
    4. using UnityEngine.Advertisements;
    5.  
    6. public class Adsbutton: MonoBehaviour {
    7.     public void ShowAd() {
    8.         if(Advertisement.IsReady()) {
    9.             Advertisement.Show();
    10.         }
    11.     }
    12. }
    13.  
    I'm using the services integrated in unity, and it appears on the dashboard, but i don´t know what I have to do.
    I tried another code, larger than this, but same thing... even initializing the ads.
     
  2. rasmus-unity

    rasmus-unity

    Moderator

    Joined:
    Aug 15, 2014
    Posts:
    1,312
    From where do you call the ShowAd() method?
     
  3. PunisherXA

    PunisherXA

    Joined:
    Jan 29, 2016
    Posts:
    11
    A button, with the event system
    When I click the button, the functions ShowAd()
     
  4. rasmus-unity

    rasmus-unity

    Moderator

    Joined:
    Aug 15, 2014
    Posts:
    1,312
    Do you get any error messages in editor when using playmode in Unity editor?
     
  5. PunisherXA

    PunisherXA

    Joined:
    Jan 29, 2016
    Posts:
    11
    No, no one.
    When I try to click the button, nothing happens
    But suddenly appeared this.
    upload_2016-11-20_15-41-42.png
     
  6. PunisherXA

    PunisherXA

    Joined:
    Jan 29, 2016
    Posts:
    11
    In console window I got nothing.
     
  7. rasmus-unity

    rasmus-unity

    Moderator

    Joined:
    Aug 15, 2014
    Posts:
    1,312
    I get this message in the Console window, when running a project with Ads enabled and have selected Android as build target:

    upload_2016-11-20_23-9-30.png

    Are you building for Android or iOS?

    /Rasmus
     
    Last edited: Nov 20, 2016
  8. PunisherXA

    PunisherXA

    Joined:
    Jan 29, 2016
    Posts:
    11
    I'm just testing ads, but I'm going to build for android
    But really, my console window is empty when I run the project
     
  9. rasmus-unity

    rasmus-unity

    Moderator

    Joined:
    Aug 15, 2014
    Posts:
    1,312
    Have you selected Android or iOS as build target in Build Settings window?
     
  10. PunisherXA

    PunisherXA

    Joined:
    Jan 29, 2016
    Posts:
    11
    Hmm in fact I didnt select anything.
    But now I have this warning

    upload_2016-11-20_16-24-36.png
     
  11. rasmus-unity

    rasmus-unity

    Moderator

    Joined:
    Aug 15, 2014
    Posts:
    1,312
    Did you sign out from Unity, since it now cannot get cloud project information? Alternatively restart Unity and make sure you are signed in with your Unity account.

    /Rasmus
     
  12. PunisherXA

    PunisherXA

    Joined:
    Jan 29, 2016
    Posts:
    11
    No I didnt, but I restarted and still the same
     
  13. rasmus-unity

    rasmus-unity

    Moderator

    Joined:
    Aug 15, 2014
    Posts:
    1,312
    Ok, not sure what exactly state "same" above means. Please make sure you are logged into Unity with your Unity developer account and have selected Android or iOS as build target. Then it should work.

    /Rasmus
     
  14. PunisherXA

    PunisherXA

    Joined:
    Jan 29, 2016
    Posts:
    11
    You were rigth, I didn't switch plattform.
    Thank you so much.
    Sorry for this long post.