private void Start() { // NOTE: the MoPub SDK needs to be initialized on Start() to ensure all other objects have been enabled first. var anyAdUnitId = _bannerAdUnits[0]; MoPub.InitializeSdk(anyAdUnitId); MoPub.LoadBannerPluginsForAdUnits(_bannerAdUnits); MoPub.LoadInterstitialPluginsForAdUnits(_interstitialAdUnits); MoPub.LoadRewardedVideoPluginsForAdUnits(_rewardedVideoAdUnits); MoPub.LoadRewardedVideoPluginsForAdUnits(_rewardedRichMediaAdUnits); #if mopub_native_beta MoPub.LoadNativePluginsForAdUnits(_nativeAdUnits); #endif #if !(UNITY_ANDROID || UNITY_IOS) Debug.LogError("Please switch to either Android or iOS platforms to run sample app!"); #endif #if UNITY_EDITOR Debug.LogWarning("No SDK was loaded since this is not on a mobile device! Real ads will not load."); #endif #if mopub_native_beta _nativeAds = new Dictionary <string, MoPubStaticNativeAd>(); var staticNativeAds = GameObject.Find("MoPubNativeAds").GetComponentsInChildren <MoPubStaticNativeAd>(); Debug.Log("Found " + staticNativeAds.Length + " mopub static native ads"); foreach (var nativeAd in staticNativeAds) { _nativeAds.Add(nativeAd.AdUnitId, nativeAd); HideNativeAd(nativeAd); } #if mopub_mediation _fbNativeAds = new Dictionary <string, FacebookNativeAd>(); var fbStaticNativeAds = GameObject.Find("MoPubNativeAds").GetComponentsInChildren <FacebookNativeAd>(); Debug.Log("Found " + fbStaticNativeAds.Length + " facebook native ads"); foreach (var fbNativeAd in fbStaticNativeAds) { _fbNativeAds.Add(fbNativeAd.AdUnitId, fbNativeAd); HideNativeAd(fbNativeAd); } #endif #else var nativeAdsGO = GameObject.Find("MoPubNativeAds"); if (nativeAdsGO != null) { nativeAdsGO.SetActive(false); } #endif }
private void Start() { // The SdkInitialize() call is handled by the MoPubManager prefab now. Please see: // https://developers.mopub.com/publishers/unity/initialize/#option-1-use-the-mopub-manager-recommended MoPub.LoadBannerPluginsForAdUnits(_bannerAdUnits); MoPub.LoadInterstitialPluginsForAdUnits(_interstitialAdUnits); MoPub.LoadRewardedVideoPluginsForAdUnits(_rewardedVideoAdUnits); MoPub.LoadRewardedVideoPluginsForAdUnits(_rewardedRichMediaAdUnits); #if mopub_native_beta MoPub.LoadNativePluginsForAdUnits(_nativeAdUnits); #endif #if !(UNITY_ANDROID || UNITY_IOS) Debug.LogError("Please switch to either Android or iOS platforms to run sample app!"); #endif #if UNITY_EDITOR Debug.LogWarning("No SDK was loaded since this is not on a mobile device! Real ads will not load."); #endif #if mopub_native_beta _nativeAds = new Dictionary <string, MoPubStaticNativeAd>(); var nativeAds = GameObject.Find("MoPubNativeAds"); if (nativeAds == null) { return; } var staticNativeAds = nativeAds.GetComponentsInChildren <MoPubStaticNativeAd>(); Debug.Log("Found " + staticNativeAds.Length + " mopub static native ads"); foreach (var nativeAd in staticNativeAds) { _nativeAds[nativeAd.AdUnitId] = nativeAd; HideNativeAd(nativeAd); } #else var nativeAdsGO = GameObject.Find("MoPubNativeAds"); if (nativeAdsGO != null) { nativeAdsGO.SetActive(false); } #endif }
private void Start() { // NOTE: the MoPub SDK needs to be initialized on Start() to ensure all other objects have been enabled first. var anyAdUnitId = _bannerAdUnits[0]; MoPub.InitializeSdk(new MoPub.SdkConfiguration { AdUnitId = anyAdUnitId, // Set desired log level here to override default level of MPLogLevelNone LogLevel = MoPubBase.LogLevel.MPLogLevelDebug, // Uncomment the following line to allow supported SDK networks to collect user information on the basis // of legitimate interest. //AllowLegitimateInterest = true, // Specify the mediated networks you are using here: MediatedNetworks = new MoPub.MediatedNetwork[] { /* * // Example using AdMob. Follow this template for other supported networks as well. * // Note that keys must be strings, and values must be JSON-serializable (strings only, for MoPubRequestOptions). * new MoPub.SupportedNetwork.AdMob * { * // Network adapter configuration settings (initialization). * NetworkConfiguration = new Dictionary<string,object> { * { "key1", value }, * { "key2", value }, * }, * * // Global mediation settings (per ad request). * MediationSettings = new Dictionary<string,object> { * { "key1", value }, * { "key2", value }, * }, * * // Additional options to pass to the MoPub servers (per ad request). * MoPubRequestOptions = new Dictionary<string,object> { * { "key1", "value" }, * { "key2", "value" }, * } * }, * * // Example using a custom network adapter: * new MoPub.MediatedNetwork * { * // Specify the class name that implements the AdapterConfiguration interface. #if UNITY_ANDROID * AdapterConfigurationClassName = "classname", // include the full package name #else // UNITY_IOS * AdapterConfigurationClassName = "classname", #endif * * // Specify the class name that implements the MediationSettings interface. * // Note: Custom network mediation settings are currently not supported on Android. #if UNITY_IOS * MediationSettingsClassName = "classname", #endif * * // Fill in settings and configuration options the same way as for supported networks: * * NetworkConfiguration = ..., * #if UNITY_IOS // See note above. * MediationSettings = ..., #endif * * MoPubRequestOptions = ..., * } */ }, }); MoPub.LoadBannerPluginsForAdUnits(_bannerAdUnits); MoPub.LoadInterstitialPluginsForAdUnits(_interstitialAdUnits); MoPub.LoadRewardedVideoPluginsForAdUnits(_rewardedVideoAdUnits); MoPub.LoadRewardedVideoPluginsForAdUnits(_rewardedRichMediaAdUnits); #if mopub_native_beta MoPub.LoadNativePluginsForAdUnits(_nativeAdUnits); #endif #if !(UNITY_ANDROID || UNITY_IOS) Debug.LogError("Please switch to either Android or iOS platforms to run sample app!"); #endif #if UNITY_EDITOR Debug.LogWarning("No SDK was loaded since this is not on a mobile device! Real ads will not load."); #endif #if mopub_native_beta _nativeAds = new Dictionary <string, MoPubStaticNativeAd>(); var nativeAds = GameObject.Find("MoPubNativeAds"); if (nativeAds == null) { return; } var staticNativeAds = nativeAds.GetComponentsInChildren <MoPubStaticNativeAd>(); Debug.Log("Found " + staticNativeAds.Length + " mopub static native ads"); foreach (var nativeAd in staticNativeAds) { _nativeAds[nativeAd.AdUnitId] = nativeAd; HideNativeAd(nativeAd); } #else var nativeAdsGO = GameObject.Find("MoPubNativeAds"); if (nativeAdsGO != null) { nativeAdsGO.SetActive(false); } #endif }
private void Start() { // NOTE: the MoPub SDK needs to be initialized on Start() to ensure all other objects have been enabled first. var anyAdUnitId = _bannerAdUnits[0]; MoPub.InitializeSdk(new MoPubBase.SdkConfiguration { AdUnitId = anyAdUnitId, AdvancedBidders = new MoPub.AdvancedBidder[] { // Add advanced bidder networks here. Uncomment one of the following, or see the AdvancedBidder // class in MoPubBase.cs for more options. //MoPub.AdvancedBidder.AdMob, //MoPub.AdvancedBidder.Facebook, //MoPub.AdvancedBidder.Tapjoy, // If necessary, you can manually add a network using the plain constructor: //new MoPub.AdvancedBidder("NetworkClassName"), // where the class name is the mediation adapter's Java or ObjC class name, minus the "AdvancedBidder" suffix. }, NetworksToInit = new MoPub.RewardedNetwork[] { // Add rewarded networks here. Uncomment one of the following, or see the RewardedVideo class // in MoPubBase.cs for more options. //MoPub.RewardedNetwork.AdColony, //MoPub.RewardedNetwork.Unity, //MoPub.RewardedNetwork.Vungle, }, MediationSettings = new MoPubBase.MediationSetting[] { // Add global mediation settings here, following the schema below (which uses AdMob as an example) //new MoPub.MediationSetting.AdMob { // { "key", "value" }, // { "key", "value" }, //}, } }); MoPub.LoadBannerPluginsForAdUnits(_bannerAdUnits); MoPub.LoadInterstitialPluginsForAdUnits(_interstitialAdUnits); MoPub.LoadRewardedVideoPluginsForAdUnits(_rewardedVideoAdUnits); MoPub.LoadRewardedVideoPluginsForAdUnits(_rewardedRichMediaAdUnits); #if mopub_native_beta MoPub.LoadNativePluginsForAdUnits(_nativeAdUnits); #endif #if !(UNITY_ANDROID || UNITY_IOS) Debug.LogError("Please switch to either Android or iOS platforms to run sample app!"); #endif #if UNITY_EDITOR Debug.LogWarning("No SDK was loaded since this is not on a mobile device! Real ads will not load."); #endif #if mopub_native_beta _nativeAds = new Dictionary <string, MoPubStaticNativeAd>(); var nativeAds = GameObject.Find("MoPubNativeAds"); if (nativeAds == null) { return; } var staticNativeAds = nativeAds.GetComponentsInChildren <MoPubStaticNativeAd>(); Debug.Log("Found " + staticNativeAds.Length + " mopub static native ads"); foreach (var nativeAd in staticNativeAds) { _nativeAds.Add(nativeAd.AdUnitId, nativeAd); HideNativeAd(nativeAd); } #else var nativeAdsGO = GameObject.Find("MoPubNativeAds"); if (nativeAdsGO != null) { nativeAdsGO.SetActive(false); } #endif }