How to place ads in a ready game + one other question

I don’t understand what you mean by this. I tried changing the Adscript to admannager, but still resulting in the same errors. This is SO frustrating.
Thanks again for all your help.

2 Likes

I’m sorry to hear this! I have completely ran out of ideas…

Earlier I posted 2 websites - the unity forum for general support and unity answers. Try asking on those websites to see if any other unity users can find an answer. This would be my best recommendation.

2 Likes

Ok, Thanks so much for your help! I will be sure to post here if I find an answer!

3 Likes

No problem! Best of luck on finding a fix to this issue :slight_smile:

2 Likes

https://forum.unity.com/threads/ads-not-working.998824/

2 Likes

I saw that someone answered! I hope it works! However it seems like they’re trying to get you to use Google AdMob. Let me know if it works!

1 Like

@Dravin, I think I had explained the problem unclearly in the question I posted on unity’s site. I cleared it up so now it states I’m only trying to use Unity Ads (I have previously tried the link that was posted about google Admob). I think my original wording was a little confusing.
Let me know if it looks better or if i missed something :slight_smile:!
Thanks!

3 Likes

Looks good to me! I hope they can find a solution to this.

If no one answers, try using Unity Answers instead of the forums as there are so many other users on that site.

2 Likes

@Greenreader9 make sure to let us know whether the problem is solved! I think you would be able to find something useful on the Unity Forum.

1 Like

Well, one thing I want to know that if I use Unity Ads or Google AdMob in my projects, can I control, that ads of which products would be shown or it would be automatically selected by the engine?

1 Like

You cannot specifically show a certain ad. This is decided by the ad network of your choice.

However, one thing you can do is have users consent to using their data to find personalized ads that are relevant for your players. You must have consent to use their data though. Not doing so is a crime as it invades their privacy if no consent is given.

1 Like

Thanks for the help @Dravin

1 Like

Hi, @Dravin, I managed to figure out why I was getting the compiler errors with the help of a support agent, I was using the wrong quotation marks. Oops. But now, (with some new code that was given to me) I GOT ADS WORKING!!! Unfortunately, It is a video ad that shows up when the game starts, not a banner ad (which we are working on to try to fix) I will share the new code once we get banner ads implemented alongside the video ad that shows on startup.

2 Likes

Yay!!! Congrats @Greenreader9!! I’m so glad to hear this!

1 Like

Thanks @Dravin! I finally got banner ads implemented but three things are messed up now.

  1. The banner ad is too large for the frame (Do I have to change it or will it fix automatically when I publish the game?)
  2. The video ad that showed in the begging of the game is gone. (how can I fix this?)
  3. Because of the banner ad, my play button is covered up. (I can just re-import the ready project to unity after making the changes in ready to fix this right? Or will that mess something else up?)

My updated code:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Advertisements;

public class AdScript : MonoBehaviour
{

#if UNITY_IOS
private string gameId = “1234567”;
#elif UNITY_ANDROID
private string gameId = “1234567”;
#endif
void Start()
{
Advertisement.Initialize(gameId, true);
StartCoroutine(ShowBannerWhenInitialized());
}

IEnumerator ShowBannerWhenInitialized()
{
    while (!Advertisement.isInitialized)
    {
        yield return new WaitForSeconds(0.5f);
        Advertisement.Banner.SetPosition(BannerPosition.BOTTOM_CENTER);
    }
    Advertisement.Banner.Show("banner");

}

}

My image of the banner ad that is too large: (My size is actually set to “16:9 Portrait (9:16)” but I changed it to “Free Aspect” so you could see the size problem better)

Please let me know how my few remaining issues can be solved.
Thanks a ton,
Greenreader9

2 Likes

Here are my answers to these questions:

  1. This should be fixed when you export the game
  2. I’m having trouble understanding this question. Could you clarify for me if possible?
  3. I recommend raising the play button to where it can be seen if the banner ad is covering it up
2 Likes

Thanks @Dravin for helping me out here,
On number two, this is what I meant.

When I contacted support the first time, I was given some code that was missed before. Its the screenshot below. If this code it attached to my object, I get a full screen ad when my app starts. (see screenshot)



After I replied to the support agent asking about the banner ad, I got some new code. (see below). If this code is attached to the object, I get a banner ad the entire time the game is open.


I would like to know how to get both types of ads to show (So a full screen when the app is opened, and a banner being ever-present after that). If I attach both scrips to the object (or different objects) I get compiler errors. Do you know of a way for this to work, or should I reply to the support agent for help?
Thanks again,
Greenreader9

2 Likes

Can I possibly see what these errors are saying? :thinking: because before I finished reading what you said my first guess was to make a separate object and put in the original code onto that separate object.

2 Likes

Hi @Dravin,
I created 2 scripts (one with each of the codes above) and the banner ad script is attached to an object. I get the following errors. Also, if I try to attach the other script (the full screen one) to an object, I get anouther error.
Again, thanks for your help!

3 Likes

Ah, i see why this is happening.

Please open the FullAd script and go to the top where it’s titled “AdScript” and name it “FullAd”

You cannot have the same script name as another script and all script names much match their titles. :slight_smile:

Please let me know if this works!

3 Likes