nabrozidhs / unity_admob_android

Basic Unity3D plugin for AdMob Google Play Services version.
MIT License
25 stars 13 forks source link

Ad Banners not showing up on Start #13

Closed kylerts closed 10 years ago

kylerts commented 10 years ago

So i got the plugin integrated with unity and build with no errors, my only problem is i have it set up to show the ad banner on the start of a specific screen, but it is only working on the click of a button, heres part of my script (below) that i try using to get the banner to show on the start of the scene. As i mentioned above the ad.showbanner works fine when i call it from a button but i want it to show on start of a scene. Any help appreciated

using UnityEngine; using System.Collections; using UnityEngine.SocialPlatforms; using GooglePlayGames;

public class startscreen : MonoBehaviour { public GUIStyle style; private const string AD_UNIT_ID = "ca-app-pub-1002713742749007/7297049382"; public AdMobPlugin admob; private bool hidden = true;

void Start () {

    admob = GetComponent<AdMobPlugin> ();
    admob.CreateBanner (AD_UNIT_ID, AdMobPlugin.AdSize.SMART_BANNER, false, "", true);
    admob.RequestAd ();
    admob.ShowBanner ();
    hidden = false;

          }

void OnGUI(){

       if (startButton) {

            if (hidden) {
                          admob.HideBanner();
                           hidden = true;

                               }

             Application.LoadLevel ("level 1");

                 }

   }
nabrozidhs commented 10 years ago

RequestAd() is not a synchronous method! You are not seeing the banner because you haven't received the ad.

If you want to be notified you need to register a callback for AdMobPlugin.AdLoaded events.

There is an example in the package.

kylerts commented 10 years ago

ok i think i understand, thank you

nabrozidhs commented 10 years ago

Let me know if you have any issues.

This article from msdn might help you understand events on C#, it did for me!

kylerts commented 10 years ago

So i have tried it and it works fine, so thanks again, much appreciated