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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Advertisement does not contain 'Banner'

Discussion in 'Unity Ads & User Acquisition' started by Reject76, Jun 27, 2020.

  1. Reject76

    Reject76

    Joined:
    Jun 12, 2015
    Posts:
    38
    Hello

    I'm so close to finish my first real release, but I can't get the banner implementation to work. Compiler is throwing this error:

    CS0117 - 'Advertisement does not contain a definition for 'Banner'. I've been trying to google and search these forums, but havent been able to find a solution. Does the Monetization SDK need to be installed? I tried installing it from the Asset Store since I cant find it in the Package Manager, but that throw some more errors around.

    I'm using:

    Unity v.2018.3.0f2
    Package Manager, v.2.0.13
    Advertisement v.2.3.2 (installed through Package Manager)

    Help? :)

    The Script is more or less taken directly from the Unity Ads tutorial:

    Code (CSharp):
    1. using System.Collections;
    2. using UnityEngine;
    3. using UnityEngine.Advertisements;
    4.  
    5. public class AdScript : MonoBehaviour
    6. {
    7.  
    8.     public string gameId = "1f52e30e-da04-4709-b5b7-0067b0befa10";
    9.     public string placementId = "bannerPlacement";
    10.     public bool testMode = true;
    11.  
    12.     void Start()
    13.     {
    14.         Advertisement.Initialize(gameId, testMode);
    15.         StartCoroutine(ShowBannerWhenReady());
    16.     }
    17.  
    18.     IEnumerator ShowBannerWhenReady()
    19.     {
    20.         while (!Advertisement.IsReady(placementId))
    21.         {
    22.             yield return new WaitForSeconds(0.5f);
    23.         }
    24.      
    25.         Advertisement.Banner.Show(placementId);
    26.      
    27.  
    28.     }
    29. }
     
  2. kyle-unity

    kyle-unity

    Unity Technologies

    Joined:
    Jan 6, 2020
    Posts:
    336
    Version 2.3.2 of the Ads SDK is quite old at this point. You should be able to install version 3.4.6 from either the package manager or asset store (but make sure you only have one of these installed at a time!). This should include the Advertisement.Banner namespace.
     
  3. Reject76

    Reject76

    Joined:
    Jun 12, 2015
    Posts:
    38
    Oooh...obviously still learning here. Didnt realize that the version number in the Package Manager was a drop down menu and that you could install multiple versions.

    The highest newer version I could find was 3.4.2 (even in the "All version" sub-category), but I installed that and it seemed to have done the trick.

    Many thanks.