• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by skurto · Dec 03, 2018 at 01:40 PM · unity ads

Unity Banner ads do not work in build

Hi guys,

So i have doing a bit of work on the implementation of Unity ads by following the integration guide - https://unityads.unity3d.com/help/unity/integration-guide-unity#implementing-banner-ads

I followed it to a T and got the non-consumable ads working great however the banner ads only seem to appear in the editor as a grey box at the bottom saying "This would be your banner ad" and this does not appear in the build.

My question is whether or not anything is supposed to appear in the build for banner ads when the game is in Test Mode.

Could anyone shed some light on the situation in relation to banner ads please? I have searched and searched and everything i have found on banner ads is either outdated or implemented using AdMob.

Many Thanks everybody

using UnityEngine.Advertisements;

public class bannerAd : MonoBehaviour {

 #if UNITY_IOS
 public const string store_id = "1234567";
 #elif UNITY_ANDROID
 public const string store_id = "1234567";
 #endif
 private string bannerPlacement = "bannerAdd";

 void Awake () {

     #if UNITY_IOS || UNITY_ANDROID
     Advertisement.Initialize (store_id, false);
     StartCoroutine (ShowBannerWhenReady ());
     #endif

 }

 IEnumerator ShowBannerWhenReady () {
     while (!Advertisement.IsReady (bannerPlacement)) {
         yield return null;
     }
     Debug.Log ("showin!");
     Advertisement.Banner.Show (bannerPlacement);
 }
 public void HideBanner (){
     Advertisement.Banner.Hide ();
 }

}

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

6 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by mauricezedde · Apr 22, 2020 at 08:10 PM

I had the same issue.


My banner was set to the canvas. As an iOS developer I am new to Unity but my understanding was that everything on the canvas would be visible in front, unless the canvas is a set as "world space".However this was not the case for the banner.


To fix this issue I placed the banner script on the camera. This fixed it for me.


To debug this I did the following:

  • I set my settings to make a build for Xcode. Then I run the program from Xcode on my iPhone. In the log I could see that the advertisement was loaded however not visible.

  • To confirm this I added a sound that would play if the banner is successfully loaded. Also this sound worked but still no banner.

  • Then I opened "Debug view Hierarchy" in Xcode. With this you can see how the view is build. I noticed there is only one view only where I would also expect a view for the banner. This made me think that the banner is behind other content/game objects.


Put the following code in a script. Change the gameId, placementId and testmode if needed and attach the script to the camera.


 using System.Collections;
 using UnityEngine;
 using UnityEngine.Advertisements;
 
 public class InitializeAdsScript : MonoBehaviour
 {
 
     public string gameId = "12345";
     public string placementId = "bannerPlacement";
     public bool testMode = true;
 
     void Start()
     {
         Advertisement.Initialize(gameId, testMode);
         Advertisement.Banner.SetPosition(BannerPosition.BOTTOM_CENTER);
         StartCoroutine(ShowBannerWhenReady());
     }
 
     IEnumerator ShowBannerWhenReady()
     {
         while (!Advertisement.IsReady(placementId))
         {
             yield return new WaitForSeconds(0.5f);
         }
         Advertisement.Banner.Show(placementId);
     }
 }


@karajohnnies, @davidhritz, @zackblack, @Bynar1M4n, @k234234w, @skurto

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
  • ‹
  • 1
  • 2

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

102 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

'This organization has been suspended' unity ads not showing 1 Answer

Ad units from Unity Ads appear very rarely 0 Answers

UnityAds and LevelLoad Problem 0 Answers

Unity Ads test mode false but it is showing test ad every time 0 Answers

Problem with Unity Ads 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges