Search Unity

Turning AdMob off during gameplay

Discussion in 'Scripting' started by AreebM, Oct 20, 2014.

  1. AreebM

    AreebM

    Joined:
    Mar 27, 2014
    Posts:
    32
    Hello fellow developers,

    For a while now I've been able to run ads on my game, with the banner appearing in my menu and then remaining throughout the different scenes in the game. What I'm having trouble with is hiding this ad banner during the gameplay.

    I've tried to use conditional statements to hide the banner:
    (my script mirrors boolean operators, I just haven't learned how to use them. Anyway this works)

    Code (CSharp):
    1.  
    2. void Update(){
    3.         hidead = otherscript1.hidead;
    4.         showad = otherscript2.showad;
    5.         if(hidead == 1){
    6.             bannerView.Hide();
    7.         }
    8.         if(showad == 1){
    9.             bannerView.Show();
    10.         }
    11.     }
    The point is that this void Update() function is placed in the Google Demo Script but it doesn't function properly, and the ads are not hidden. I don't think the Update function is meant to be placed in that script but I don't know where to go from here. Can anyone help me?