Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Feedback Admob ads static script

Discussion in 'Unity Ads & User Acquisition' started by Rickard87, Jun 11, 2022.

  1. Rickard87

    Rickard87

    Joined:
    Oct 12, 2021
    Posts:
    38
    Is it a better idea to use a static script for loading admob ads instead of loading at the start of every scene? For me it seems that ads don't have time to load a lot of the time but I haven't seen anyone using that way.
    I currently use 1 Ad Manager gameobject for every scene with the script attached.

    Thank you for your feedback
     
  2. xGeorgeV

    xGeorgeV

    Joined:
    Aug 8, 2013
    Posts:
    63
    Admob belongs to Google.
    Good idea using "public static class AdMobAndroid"...
     
    Rickard87 likes this.
  3. Rickard87

    Rickard87

    Joined:
    Oct 12, 2021
    Posts:
    38
    What do you mean? Are you saying I should use public static class and not Monobehaviour?
     
  4. xGeorgeV

    xGeorgeV

    Joined:
    Aug 8, 2013
    Posts:
    63
    Sure!

    AdMobAndroid.createBanner();

    Code (CSharp):
    1. public static class AdMobAndroid
    2. {
    3.     // ===========================================================================
    4.     //                                 AdMobAndroid
    5.     // ===========================================================================
    6.  
    7.     static AdMobAndroid()
    8.     {
    9.         if( Application.platform != RuntimePlatform.Android ) { return; }
    10.     }
    11.  
    12.     // ===========================================================================
    13.     //                                 BannerAd
    14.     // ===========================================================================
    15.  
    16.     public static void createBanner()
    17.     { ... }
    18. }
    19.  
     
    Rickard87 likes this.
  5. Rickard87

    Rickard87

    Joined:
    Oct 12, 2021
    Posts:
    38
    May I know for what reason/reasons you prefer this over Monobehaviour setup?
    I got some logcatting done and seems that something of Exoplayer is making an error possibly causing my ads to stop showing up. Lots and lots of problems *sigh*
     
  6. xGeorgeV

    xGeorgeV

    Joined:
    Aug 8, 2013
    Posts:
    63
    "May I know for what reason/reasons you prefer this over Monobehaviour setup?"

    You can use it in the whole code, everywhere...