Search Unity

Destroy Startapp ad banner from Scene

Discussion in 'Editor & General Support' started by mackvnk, Jan 21, 2014.

  1. mackvnk

    mackvnk

    Joined:
    Jan 21, 2014
    Posts:
    2
    Hi,

    I am developing a game and i implement a startapp ad plugin in that. I used a banner ad in my scene but after some user input i want to remove or hide that banner from scene so how i remove/hide that startapp banner?

    Please reply me if anyone have an idea of this
    Thanks in advance...
     
  2. lorenalexm

    lorenalexm

    Joined:
    Dec 14, 2012
    Posts:
    307
    If the banner is being contained within it's own GameObject, you can keep a reference to the object and use the SetActive method to disable or enable it at will. If it is a component, you again should reference or retrieve with the GetComponent template and set the enabled/active flag from there.
     
  3. mackvnk

    mackvnk

    Joined:
    Jan 21, 2014
    Posts:
    2
    Well, i create one prefab object with the banner ad script, and try to add that in screen on runtime and destroy where i want to hide, but can't succeed.
    Also try to remove that gameobject from scene in runtime.

    So if you done that can you give me little detailed solution for that?
     
  4. lorenalexm

    lorenalexm

    Joined:
    Dec 14, 2012
    Posts:
    307
    I apologize, but without being able to see the code you are using currently there isn't a whole lot more that I can do than explain the principle concepts behind a possible solution.
     
  5. Deleted User

    Deleted User

    Guest

    I am also experiencing this issue.

    Currently I have a single game object on my main menu [called androidAdBanner"] that contains the prebuilt StartApp script that came with the SDK. Looks like this:

    using UnityEngine;
    using System.Collections;
    using StartApp;

    public class SmartAppBanner : MonoBehaviour {

    // Use this for initialization
    void Start () {
    StartAppWrapper.addBanner (
    StartAppWrapper.BannerType.AUTOMATIC,
    StartAppWrapper.BannerPosition.TOP);

    }
    }


    But I just want to hide it on a particular game scene.

    How can I do this?
     
  6. Deleted User

    Deleted User

    Guest

  7. Dogg

    Dogg

    Joined:
    Mar 5, 2014
    Posts:
    203
    I'm also wanting to hide/destroy an ad banner when certain scenes load. I'm using this script attached to an empty game object:

    Code (CSharp):
    1. public class IAdScript : MonoBehaviour {
    2.  
    3.     private ADBannerView banner = null;
    4.     void Start()
    5.     {
    6.         banner = new ADBannerView(ADBannerView.Type.Banner, ADBannerView.Layout.Bottom);
    7.         ADBannerView.onBannerWasClicked += OnBannerClicked;
    8.         ADBannerView.onBannerWasLoaded  += OnBannerLoaded;
    9.     }
    10.    
    11.     void OnBannerClicked()
    12.     {
    13.         Debug.Log("Clicked!\n");
    14.     }
    15.    
    16.     void OnBannerLoaded()
    17.     {
    18.         Debug.Log("Loaded!\n");
    19.         banner.visible = true;
    20.     }
    21.    
    22. }
    I tried something similar to what lorenalexm said. I used GameObject.active = false but that didn't work when I ran a test on the actual device. All it seemed to do was lag me and freeze my game, but I'll try it again one more time. If anyone has any suggestions, please feel free to share them. Don't worry, I won't bite you. :)
     
  8. Nadan

    Nadan

    Joined:
    Jan 20, 2013
    Posts:
    341
    I'm having same problem here. Did you happen to find any solution for this?
     
  9. Dogg

    Dogg

    Joined:
    Mar 5, 2014
    Posts:
    203
    Yes I did. Okay here's how i did it. First take a look at this script:

    Code (CSharp):
    1. public class AdtestGone : MonoBehaviour {
    2.  
    3.     private ADBannerView banner= null;
    4.     private bool show = true;
    5.     bool hide = false;
    6.    
    7.     void Start(){
    8.         show = true;
    9.     }
    10.    
    11.     void Update () {
    12.         if (banner == null && show == true) {
    13.             CreateBanner ();
    14.         }
    15.         if (hide == true) {
    16.             Debug.Log("Hide");
    17.             if (banner != null) {
    18.                 show = false;
    19.                 banner.visible = false;
    20.                 banner = null;
    21.                 ADBannerView.onBannerWasLoaded -= OnBannerLoaded;
    22.                
    23.             }
    24.         }
    25.     }
    26.    
    27.     void CreateBanner(){
    28.         banner = new ADBannerView(ADBannerView.Type.Banner, ADBannerView.Layout.Bottom);
    29.         ADBannerView.onBannerWasLoaded  += OnBannerLoaded;
    30.     }
    31.    
    32.     public void HideBanner()
    33.     {
    34.         Debug.Log ("HideBanner");
    35.         hide = true;
    36.     }
    37.     void OnBannerLoaded()
    38.     {
    39.         Debug.Log("Loaded!\n");
    40.         banner.visible = true;
    41.     }
    42. }
    This is the script I use for my ads. I recommend using it. Okay so next I drag this script onto an empty game object in the scene that I want it to appear in. I chose the main menu to display my ads. So I have three GUI buttons that take me to different scenes. In the main menu script where the GUI buttons are, I do this:

    Code (CSharp):
    1. public AdtestGone other;
    2.  
    3. void OnGUI(){
    4.        
    5.         if (GUI.Button (new Rect (Screen.width * guiPlacementX1, Screen.height * guiPlacementY1, Screen.width * .5f, Screen.height * .1f), "Play Game")) {              
    6.             other.HideBanner();
    7.             Application.LoadLevel ("Level1");
    I tell the script to hide the banner, and it does. Call other.HideBanner() every time you want to hide your banner. Test it out on your device and see if it works for you. It worked for me, and my game is now on the App Store. Hope this helps you.
     
  10. Nadan

    Nadan

    Joined:
    Jan 20, 2013
    Posts:
    341
    Thank you for the help, Dogg! Seems to be working. :)
     
    Dogg likes this.
  11. Dogg

    Dogg

    Joined:
    Mar 5, 2014
    Posts:
    203
    No problem! ;)
     
    Nadan likes this.
  12. Ardiyas

    Ardiyas

    Joined:
    Jul 26, 2017
    Posts:
    1
    thank you so much dudde.. :)
     
  13. SAditya

    SAditya

    Joined:
    May 21, 2019
    Posts:
    19
    As of December 31, 2016, the iAd App Network is no longer available.
    The following classes and their APIs in the iAd SDK are deprecated:

    • ADBannerView
    • ADInterstitialAd
    • UIViewController (iAdAdditions)
    • AVPlayerViewController (iAdPreroll)
    • MPMoviePlayerController (iAdPreroll)
    • ADBannerViewDelegate
    • ADInterstitialAdDelegate