- Home /
 
Can't Hide AdMob Ads Banner
guys im in very beginning learning code in unity. I have my AdMobs script which places the banners, which I just want to place it on my shop screen. but I have problem coding it everyone in internet said if we want to hide the banner ads, we just had to put simple code like bannerView.Hide (); but when I try it, my monodevelop said that "bannerView" doesnt exist
here is my code
 ![void Start () {
         // Create a 320x50 banner at the top of the screen.
         BannerView bannerView = new BannerView("ca-app-pub-xxxxx/xxxxxx", AdSize.Banner, AdPosition.Top);
         // Create an empty ad request.
         AdRequest request = new AdRequest.Builder()
             .AddTestDevice(AdRequest.TestDeviceSimulator)       // Simulator
             .Build();
         // Load the banner with the request.
         bannerView.LoadAd(request);
     }
 
 void Update()
     {
         
         if (shopscreen.activeInHierarchy == true)
         {
             bannerView.Hide ();
             Debug.Log("SHOW AD banner");
         }
         else if(shopscreen.activeInHierarchy == false)
         {
             bannerView.Show();
         
     }][1]
 
               help please ..
[1]: /storage/temp/97448-screenshot-324.png
Answer by ShadyProductions · Jul 10, 2017 at 09:34 AM
You have to declare BannerView variable outside of the method, so that you can use it anywhere and not just the method you declared it into. Like so:
 private BannerView bannerView;
 
 void Start() {
 bannerView = new BannerView("ca-app-pub-xxxxx/xxxxxx", AdSize.Banner, AdPosition.Top);
 //blabla
 }
 
 void Update() {
 bannerView.Hide();
 //blabla
 }
 
              thank you!! Its really hard for me because Im just a graphic designer artist before and doesn't have much background in program$$anonymous$$g sry for bad english
Your answer
 
             Follow this Question
Related Questions
Admob ads not showing when using Unity 2018 0 Answers
How to make your script function every 5 times it is called. 1 Answer
ADmob Hide banner,Destroy banner 1 Answer
Admob ads don't work 0 Answers