private void CreateInterstitialsSection() { GUILayout.Space((float)this._sectionMarginSize); GUILayout.Label("Interstitials", new GUILayoutOption[0]); if (!MoPubDemoGUI.IsAdUnitArrayNullOrEmpty(this._interstitialAdUnits)) { foreach (string text in this._interstitialAdUnits) { GUILayout.BeginHorizontal(new GUILayoutOption[0]); GUI.enabled = !this._adUnitToLoadedMapping[text]; if (GUILayout.Button(MoPubDemoGUI.CreateRequestButtonLabel(text), new GUILayoutOption[0])) { UnityEngine.Debug.Log("requesting interstitial with AdUnit: " + text); this._status = "Requesting " + text; MoPubAndroid.RequestInterstitialAd(text, string.Empty, string.Empty); } GUI.enabled = this._adUnitToLoadedMapping[text]; if (GUILayout.Button("Show", new GUILayoutOption[0])) { this._status = string.Empty; MoPubAndroid.ShowInterstitialAd(text); } GUI.enabled = true; GUILayout.EndHorizontal(); } } else { GUILayout.Label("No interstitial AdUnits available", this._smallerFont, null); } }
private void Awake() { if (this._demoGUI == null) { this._demoGUI = base.GetComponent <MoPubDemoGUI>(); } if (this._demoGUI == null) { Debug.LogError("Missing reference to MoPubDemoGUI. Please fix in the editor."); Object.Destroy(this); } }
private void Awake() { if (_demoGUI == null) { _demoGUI = GetComponent <MoPubDemoGUI>(); } if (_demoGUI != null) { return; } Debug.LogError("Missing reference to MoPubDemoGUI. Please fix in the editor."); Destroy(this); }
private void CreateRewardedRichMediaSection() { GUILayout.Space((float)this._sectionMarginSize); GUILayout.Label("Rewarded Rich Media", new GUILayoutOption[0]); if (!MoPubDemoGUI.IsAdUnitArrayNullOrEmpty(this._rewardedRichMediaAdUnits)) { MoPubDemoGUI.CreateCustomDataField("rrmCustomDataField", ref this._rrmCustomData); foreach (string text in this._rewardedRichMediaAdUnits) { GUILayout.BeginHorizontal(new GUILayoutOption[0]); GUI.enabled = !this._adUnitToLoadedMapping[text]; if (GUILayout.Button(MoPubDemoGUI.CreateRequestButtonLabel(text), new GUILayoutOption[0])) { UnityEngine.Debug.Log("requesting rewarded rich media with AdUnit: " + text); this._status = "Requesting " + text; MoPubAndroid.RequestRewardedVideo(text, null, "rewarded, video, mopub", null, 37.7833, 122.4167, "customer101"); } GUI.enabled = this._adUnitToLoadedMapping[text]; if (GUILayout.Button("Show", new GUILayoutOption[0])) { this._status = string.Empty; MoPubAndroid.ShowRewardedVideo(text, MoPubDemoGUI.GetCustomData(this._rrmCustomData)); } GUI.enabled = true; GUILayout.EndHorizontal(); if (MoPubAndroid.HasRewardedVideo(text) && this._adUnitToRewardsMapping.ContainsKey(text) && this._adUnitToRewardsMapping[text].Count > 1) { GUILayout.BeginVertical(new GUILayoutOption[0]); GUILayout.Space((float)this._sectionMarginSize); GUILayout.Label("Select a reward:", new GUILayoutOption[0]); foreach (MoPubBase.Reward selectedReward in this._adUnitToRewardsMapping[text]) { if (GUILayout.Button(selectedReward.ToString(), new GUILayoutOption[0])) { MoPubAndroid.SelectReward(text, selectedReward); } } GUILayout.Space((float)this._sectionMarginSize); GUILayout.EndVertical(); } } } else { GUILayout.Label("No rewarded rich media AdUnits available", this._smallerFont, null); } }
private void CreateBannersSection() { GUILayout.Space(102f); GUILayout.Label("Banners", new GUILayoutOption[0]); if (!MoPubDemoGUI.IsAdUnitArrayNullOrEmpty(this._bannerAdUnits)) { foreach (string text in this._bannerAdUnits) { GUILayout.BeginHorizontal(new GUILayoutOption[0]); GUI.enabled = !this._adUnitToLoadedMapping[text]; if (GUILayout.Button(MoPubDemoGUI.CreateRequestButtonLabel(text), new GUILayoutOption[0])) { UnityEngine.Debug.Log("requesting banner with AdUnit: " + text); this._status = "Requesting " + text; MoPubAndroid.CreateBanner(text, MoPubBase.AdPosition.BottomCenter); } GUI.enabled = this._adUnitToLoadedMapping[text]; if (GUILayout.Button("Destroy", new GUILayoutOption[0])) { this._status = string.Empty; MoPubAndroid.DestroyBanner(text); this._adUnitToLoadedMapping[text] = false; this._adUnitToShownMapping[text] = false; } GUI.enabled = (this._adUnitToLoadedMapping[text] && !this._adUnitToShownMapping[text]); if (GUILayout.Button("Show", new GUILayoutOption[0])) { this._status = string.Empty; MoPubAndroid.ShowBanner(text, true); this._adUnitToShownMapping[text] = true; } GUI.enabled = (this._adUnitToLoadedMapping[text] && this._adUnitToShownMapping[text]); if (GUILayout.Button("Hide", new GUILayoutOption[0])) { this._status = string.Empty; MoPubAndroid.ShowBanner(text, false); this._adUnitToShownMapping[text] = false; } GUI.enabled = true; GUILayout.EndHorizontal(); } } else { GUILayout.Label("No banner AdUnits available", this._smallerFont, null); } }
void OnEnable() { var type = typeof(MoPubDemoGUI); try { // first we see if the Demo GUI already exist in the scene _demoGUI = FindObjectOfType(type) as MoPubDemoGUI; if (_demoGUI == null) { Debug.LogWarning("MoPubDemoGUI not initialized."); } } catch (UnityException e) { Debug.LogException(e); } // Listen to all events for illustration purposes MoPubManager.onAdLoadedEvent += onAdLoadedEvent; MoPubManager.onAdFailedEvent += onAdFailedEvent; MoPubManager.onAdClickedEvent += onAdClickedEvent; MoPubManager.onAdExpandedEvent += onAdExpandedEvent; MoPubManager.onAdCollapsedEvent += onAdCollapsedEvent; MoPubManager.onInterstitialLoadedEvent += onInterstitialLoadedEvent; MoPubManager.onInterstitialFailedEvent += onInterstitialFailedEvent; MoPubManager.onInterstitialShownEvent += onInterstitialShownEvent; MoPubManager.onInterstitialClickedEvent += onInterstitialClickedEvent; MoPubManager.onInterstitialDismissedEvent += onInterstitialDismissedEvent; MoPubManager.onInterstitialExpiredEvent += onInterstitialExpiredEvent; MoPubManager.onRewardedVideoLoadedEvent += onRewardedVideoLoadedEvent; MoPubManager.onRewardedVideoFailedEvent += onRewardedVideoFailedEvent; MoPubManager.onRewardedVideoExpiredEvent += onRewardedVideoExpiredEvent; MoPubManager.onRewardedVideoShownEvent += onRewardedVideoShownEvent; MoPubManager.onRewardedVideoClickedEvent += onRewardedVideoClickedEvent; MoPubManager.onRewardedVideoFailedToPlayEvent += onRewardedVideoFailedToPlayEvent; MoPubManager.onRewardedVideoReceivedRewardEvent += onRewardedVideoReceivedRewardEvent; MoPubManager.onRewardedVideoClosedEvent += onRewardedVideoClosedEvent; MoPubManager.onRewardedVideoLeavingApplicationEvent += onRewardedVideoLeavingApplicationEvent; }
private void OnImpressionTrackedEventBg(string adUnitId, MoPub.ImpressionData impressionData) { MoPubDemoGUI.ImpressionTrackedBg(adUnitId, impressionData); }