void Awake() { if (ads != null) { DestroyImmediate(gameObject); } else { ads = this; DontDestroyOnLoad(gameObject); } }
private void Interstitial_OnAdFailedToLoad(object sender, AdFailedToLoadEventArgs e) { //OnInterstitialAdFailedToLoad(); isInterstitialLoaded = false; if (!isReloadIntertitial) { isReloadIntertitial = true; SG_AdManager.RequestFanIntertitial(); } }
private void Banner_OnAdFailedToLoad(object sender, AdFailedToLoadEventArgs e) { //OnAdFailedToLoad(); Debug.Log("Banner_OnAdFailedToLoad"); DestroyBanner(); if (!isReloadBanner) { isReloadBanner = true; SG_AdManager.RequestFanBanner(); } }
void ShowIntertitial() { SG_AdManager.HideAdmobBanner(); SG_AdManager.ads.RequestIntertitial(); SG_AdManager.ads.ShowIntertitial(); }
public void RequestBanner() { //Debug.Log("RequestBanner"); // Create a banner's ad view with a unique placement ID (generate your own on the Facebook app settings). // Use different ID for each ad placement in your app. AdView adView = new AdView(RemoteSettingsHandler.remoteSettingsHandler.fan_banner_id, AdSize.BANNER_HEIGHT_50); this.banner = adView; this.banner.Register(this.gameObject); // Set delegates to get notified on changes or when the user interacts with the ad. this.banner.AdViewDidLoad = (delegate() { //Debug.Log("Ad view loaded."); isBannerLoaded = true; //isReloadBanner = false; //this.adView.Show(AdUtility.height() - 50); //this.adView.Show(100); SG_AdManager.ads.ShowBanner(); }); adView.AdViewDidFailWithError = (delegate(string error) { //Debug.Log("Ad view failed to load with error: " + error); isBannerLoaded = false; DisposeBanner(); if (!isFirstReLoadBanner) { isFirstReLoadBanner = true; RequestBanner(); } else { if (!isReloadBanner) { //Debug.Log("ReloadBanner"); isReloadBanner = true; SG_AdManager.ads.googleAdsManager.InitAdmob(); SG_AdManager.RequestAdmobBanner(); } } }); adView.AdViewWillLogImpression = (delegate() { //Debug.Log("Ad view logged impression."); //FireBaseController.LogEvent("fan_banner_impression", "state_name", MainState.state.ToString()); }); adView.AdViewDidClick = (delegate() { //Debug.Log("Ad view clicked."); //FireBaseController.LogEvent("fan_banner_click", "state_name", MainState.state.ToString()); }); // Initiate a request to load an ad. adView.LoadAd(); }
public void RequestInterstitial() { if (isIntertitialLoaded) { return; } //Debug.Log("RequestInterstitial"); // Create the interstitial unit with a placement ID (generate your own on the Facebook app settings). // Use different ID for each ad placement in your app. InterstitialAd interstitialAd = new InterstitialAd(RemoteSettingsHandler.remoteSettingsHandler.fan_interstitial_id); this.interstitialAd = interstitialAd; this.interstitialAd.Register(this.gameObject); // Set delegates to get notified on changes or when the user interacts with the ad. this.interstitialAd.InterstitialAdDidLoad = (delegate() { //Debug.Log("Interstitial ad loaded."); isIntertitialLoaded = true; //isReloadIntertitial = false; }); interstitialAd.InterstitialAdDidFailWithError = (delegate(string error) { //Debug.Log("Interstitial ad failed to load with error: " + error); isIntertitialLoaded = false; if (!isFirstReloadIntertitial) { isFirstReloadIntertitial = true; RequestInterstitial(); } else { if (!isReloadIntertitial) { //Debug.Log("Reload Interstitial"); isReloadIntertitial = true; SG_AdManager.ads.googleAdsManager.InitAdmob(); SG_AdManager.RequestAdmobInterstitial(); } } }); interstitialAd.InterstitialAdWillLogImpression = (delegate() { //Debug.Log("Interstitial ad logged impression."); //FireBaseController.LogEvent("fan_intertitial_impression", "state_name", MainState.state.ToString()); }); interstitialAd.InterstitialAdDidClick = (delegate() { //Debug.Log("Interstitial ad clicked."); //FireBaseController.LogEvent("fan_intertitial_click", "state_name", MainState.state.ToString()); }); interstitialAd.interstitialAdDidClose = (delegate() { //Debug.Log("Interstitial ad closed."); //Time.timeScale = 1f; //MainAudio.Main.MuteSound((Settings.GetSound == 1) ? false : true); isIntertitialLoaded = false; GoogleAds.isInterstitialLoaded = false; SG_AdManager.ads.RequestIntertitial(); //if (MainState.state == MainState.State.Ingame) //{ // //RequestInterstitial(); // SG_AdManager.ads.RequestIntertitial(); //} }); // Initiate the request to load the ad. this.interstitialAd.LoadAd(); }