I have the default unity ads set, which is shown once every time the “GameOver” scene is loaded. The user’s feedback are saying its too much! I would like to set the ads so they are shown once every three times the “GameOver” scene is loaded, please be specific and detailed, I am not very good at C#. Thanks.
This is my script.
If I’ve understood you correctly, this should do it:
using UnityEngine;
using UnityEngine.Advertisements;
public class Ads : MonoBehaviour
{
static int loadCount = 0;
void Start()
{
if (loadCount % 3 == 0) // only show ad every third time
{
ShowAd ();
}
loadCount++;
}
public void ShowAd()
{
if (Advertisement.IsReady())
{
Advertisement.Show();
}
}
}
Sorry one quick question i have this setup and it works well (I changed to every 6 loads) only issue i have it when i click start game it plays add then i die 6 times then it loads.
Its like it always plays the ad once first then every 6 times. Is there a way to stop it playing the first time and only after the first x number of deaths
using UnityEngine;
using UnityEngine.Advertisements;
public class ads : MonoBehaviour
{
static int loadCount = 1;
void Start()
{
if (loadCount % 6+1 == 0) // only show ad every third time
{
ShowAd ();
}
loadCount++;
}
public void ShowAd()
{
if (Advertisement.IsReady())
{
Advertisement.Show();
}
}
}
Hello Guys
I’m also not very familiar with showing ads
I have successfully showed unity ads with the method in the first comments thanks to rasmus-unity and NikolaTotev
but I still struggle with other network ads such as admob and chartboost, Their SDK is kind of hard to me.
I want to do the same thing with admob (Showing Interstitial Ads After 3 gameplays), I’m using a plugin from unity asset store called “very easy ads” but i still can’t implement ads correctly.
If someone already did what i want to do, please help me show ads too
I rebuilt my game from scratch.
No more player script error.
I am now getting the following error using the script by rasmus-unity.
"
UnityAdsEditor: Initialize(gameID, True);
UnityEditor.Advertisements.UnityAdsEditor:EditorOnLoad()"
The test ad does not show.
I have build setting to use Android.
Is there a way to fix this?
I am using Unity 5.6.5f1
@incenseman , are you using Asset Store or engine integrated version of Ads SDK? And what do you mean by errors, does they have the red error icon next to them (looks like those messages are from Console window in editor)
I am using the integrated ads SDK. It is in from Console window in editor and has an exclamation point in a white text bubble like from a comic strip.
I have removed all ad related scripts and still get the same thing.
The only way I do not see this issue is when ads are off.
Re-added your script and now am getting this:
“error CS0234: The type or namespace name Advertisements' does not exist in the namespace UnityEngine’. Are you missing an assembly reference?”
“engine integrated ads” means when you are using the Services window in Unity editor to enable ads, see “Services Window method” section on Unity developer integration guides