[ad_1]
Sport Improvement Stack Alternate is a query and reply website for skilled and impartial recreation builders. It solely takes a minute to enroll.
Anyone can ask a query
Anyone can reply
The perfect solutions are voted up and rise to the highest
Requested
Considered
2k occasions
I’ve create a Unity recreation, 1st I add an AdMob interstitial adverts script on recreation object then strive on my fundamental digital camera after I check in my cellular earlier than publishing. It has labored like actual time adverts and mistakenly clicked it and earn 0.3 so I create new advert unit positioned it on my recreation then revealed my recreation. However the adverts will not be exhibiting in actual time. No error was present in AdMob however 147 advert requests are proven in AdMob and adverts will not be seen when my recreation 1st scene opens.
Right here is my interstitial adverts script code:
utilizing UnityEngine;
utilizing System.Collections;
utilizing GoogleMobileAds.Api;
public class AdmobScript : MonoBehaviour
{
personal InterstitialAd interstitial;
personal 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.LoadAd(this.CreateAdRequest());
}
// Returns an advert request
personal AdRequest CreateAdRequest()
{
return new AdRequest.Builder().Construct();
}
personal void ShowInterstitial()
{
if (interstitial.IsLoaded())
{
interstitial.Present();
}
}
public void Begin()
{
RequestInterstitial();
}
void Gameover()
{
if(interstitial.isloaded){
ShowInterstitial();
}
}
}
$endgroup$
1
The advert want a Construct request operate. Execute the beneath code and run on the testing system. for those who obtained check adverts then certainly it’s going to open in play retailer model additionally. Then replace the brand new construct in play retailer.
personal 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().Construct();
// Load the interstitial with the request.
this.interstitial.LoadAd(request);
}
The advert calling methodology should be like this
personal void GameOver()
{
if (this.interstitial.IsLoaded()) {
this.interstitial.Present();
}else{
RequestInterstial();
}
}
$endgroup$
2
You could log in to reply this query.
Not the reply you are searching for? Browse different questions tagged .
lang-cs
[ad_2]