[ad_1]
Game Development Stack Exchange is a query and reply web site for skilled and unbiased recreation builders. It solely takes a minute to enroll.
Anybody can ask a query
Anybody can reply
The finest solutions are voted up and rise to the highest
Asked
Viewed
2k instances
I’ve create a Unity recreation, 1st I add an AdMob interstitial advertisements script on recreation object then attempt on my foremost digicam after I take a look at in my cellular earlier than publishing. It has labored like actual time advertisements and mistakenly clicked it and earn 0.3 so I create new advert unit positioned it on my recreation then printed my recreation. But the advertisements usually are not exhibiting in actual time. No error was present in AdMob however 147 advert requests are proven in AdMob and advertisements usually are not seen when my recreation 1st scene opens.
Here is my interstitial advertisements script code:
utilizing UnityEngine;
utilizing System.Collections;
utilizing GoogleMobileAds.Api;
public class AdmobScript : MonoBehaviour
{
non-public InterstitialAd interstitial;
non-public void RequestInterstitial()
{
#if UNITY_ANDROID
string adUnitId = "ca-app-pub-3129337025883034/9036322***";
#elif UNITY_IPHONE
string adUnitId = "INSERT_IOS_INTERSTITIAL_AD_UNIT_ID_HERE";
#else
string adUnitId = "unexpected_platform";
#endif
// Create an interstitial.
this.interstitial = new InterstitialAd(adUnitId);
// Load an interstitial advert.
this.interstitial.LoadAdvert(this.CreateAdRequest());
}
// Returns an advert request
non-public AdRequest CreateAdRequest()
{
return new AdRequest.Builder().Build();
}
non-public void ShowInterstitial()
{
if (interstitial.IsLoaded())
{
interstitial.Show();
}
}
public void Start()
{
RequestInterstitial();
}
void Gameover()
{
if(interstitial.isloaded){
ShowInterstitial();
}
}
}
$endgroup$
1
The advert want a Build request operate. Execute the under code and run on the testing gadget. if you happen to bought take a look at advertisements then certainly it is going to open in play retailer model additionally. Then replace the brand new construct in play retailer.
non-public void RequestInterstitial()
{
#if UNITY_ANDROID
string adUnitId = "ca-app-pub-3129337025883034/9036322***";
#elif UNITY_IPHONE
string adUnitId = "INSERT_IOS_INTERSTITIAL_AD_UNIT_ID_HERE";
#else
string adUnitId = "unexpected_platform";
#endif
// Create an interstitial.
this.interstitial = new InterstitialAd(adUnitId);
// Create an empty advert request.
AdRequest request = new AdRequest.Builder().Build();
// Load the interstitial with the request.
this.interstitial.LoadAdvert(request);
}
The advert calling technique have to be like this
non-public void GameOver()
{
if (this.interstitial.IsLoaded()) {
this.interstitial.Show();
}else{
RequestInterstial();
}
}
$endgroup$
2
You should log in to reply this query.
Not the reply you are searching for? Browse different questions tagged .
lang-cs
[ad_2]