// This script is used for Unity Editor and non Android or iOS platforms. #if UNITY_EDITOR || !(UNITY_ANDROID || UNITY_IPHONE || UNITY_IOS) using System; using System.Collections; using System.Collections.Generic; using System.Globalization; using AppLovinMax.Internal; using AppLovinMax.ThirdParty.MiniJson; #if UNITY_EDITOR using UnityEditor; #endif using UnityEngine; using UnityEngine.UI; using Object = UnityEngine.Object; /// /// Unity Editor AppLovin MAX Unity Plugin implementation /// public class MaxSdkUnityEditor : MaxSdkBase { private static bool _isInitialized; private static bool _hasSdkKey; private static bool _hasUserConsent = false; private static bool _isUserConsentSet = false; private static bool _isAgeRestrictedUser = false; private static bool _isAgeRestrictedUserSet = false; private static bool _doNotSell = false; private static bool _isDoNotSellSet = false; private static bool _showStubAds = true; private static SafeAreaInsets _safeAreaInsets = new SafeAreaInsets(new int[] {0, 0, 0, 0}); private static readonly HashSet RequestedAdUnits = new HashSet(); private static readonly HashSet ReadyAdUnits = new HashSet(); private static readonly Dictionary StubBanners = new Dictionary(); public static MaxUserServiceUnityEditor UserService { get { return MaxUserServiceUnityEditor.Instance; } } [RuntimeInitializeOnLoadMethod] public static void InitializeMaxSdkUnityEditorOnLoad() { // Unity destroys the stub banners each time the editor exits play mode, but the StubBanners stays in memory if Enter Play Mode settings is enabled. StubBanners.Clear(); } /// /// Set AppLovin SDK Key. /// /// This method must be called before any other SDK operation /// /// AppLovin SDK key. Must not be null. public static void SetSdkKey(string sdkKey) { _hasSdkKey = true; } #region Initialization /// /// Initialize the default instance of AppLovin SDK. /// /// Please make sure that application's Android manifest or Info.plist includes the AppLovin SDK key. /// /// /// OPTIONAL: Set the MAX ad unit ids to be used for this instance of the SDK. 3rd-party SDKs will be initialized with the credentials configured for these ad unit ids. /// This should only be used if you have different sets of ad unit ids / credentials for the same package name. /// public static void InitializeSdk(string[] adUnitIds = null) { _ensureHaveSdkKey(); _isInitialized = true; _hasSdkKey = true; // Slight delay to emulate the SDK initializing ExecuteWithDelay(0.1f, () => { _isInitialized = true; #if UNITY_EDITOR MaxSdkCallbacks.EmitSdkInitializedEvent(); #endif }); } /// /// Check if the SDK has been initialized. /// /// True if SDK has been initialized public static bool IsInitialized() { return _isInitialized; } /// /// Prevent stub ads from showing in the Unity Editor /// public static void DisableStubAds() { _showStubAds = false; } #endregion #region User Info /// /// Set an identifier for the current user. This identifier will be tied to SDK events and our optional S2S postbacks. /// /// If you're using reward validation, you can optionally set an identifier to be included with currency validation postbacks. /// For example, a username or email. We'll include this in the postback when we ping your currency endpoint from our server. /// /// /// The user identifier to be set. Must not be null. public static void SetUserId(string userId) { } /// /// User segments allow us to serve ads using custom-defined rules based on which segment the user is in. For now, we only support a custom string 32 alphanumeric characters or less as the user segment. /// public static MaxUserSegment UserSegment { get { return SharedUserSegment; } } /// /// This class allows you to provide user or app data that will improve how we target ads. /// public static MaxTargetingData TargetingData { get { return SharedTargetingData; } } #endregion #region MAX /// /// Returns the list of available mediation networks. /// /// Please call this method after the SDK has initialized. /// public static List GetAvailableMediatedNetworks() { return new List(); } /// /// Present the mediation debugger UI. /// This debugger tool provides the status of your integration for each third-party ad network. /// /// Please call this method after the SDK has initialized. /// public static void ShowMediationDebugger() { if (!_isInitialized) { MaxSdkLogger.UserWarning("The mediation debugger cannot be shown before the MAX SDK has been initialized." + "\nCall 'MaxSdk.InitializeSdk();' and listen for 'MaxSdkCallbacks.OnSdkInitializedEvent' before showing the mediation debugger."); } else { MaxSdkLogger.UserWarning("The mediation debugger cannot be shown in the Unity Editor. Please export the project to Android or iOS first."); } } /// /// Present the mediation debugger UI. /// /// Please call this method after the SDK has initialized. /// public static void ShowCreativeDebugger() { if (!_isInitialized) { MaxSdkLogger.UserWarning("The creative debugger cannot be shown before the MAX SDK has been initialized." + "\nCall 'MaxSdk.InitializeSdk();' and listen for 'MaxSdkCallbacks.OnSdkInitializedEvent' before showing the mediation debugger."); } else { MaxSdkLogger.UserWarning("The creative debugger cannot be shown in the Unity Editor. Please export the project to Android or iOS first."); } } /// /// Returns the arbitrary ad value for a given ad unit identifier with key. Returns null if no ad is loaded. /// /// Ad unit identifier for which to get the ad value for. Must not be null. /// Ad value key. Must not be null. /// Arbitrary ad value for a given key, or null if no ad is loaded. public static string GetAdValue(string adUnitIdentifier, string key) { return ""; } #endregion #region Privacy /// /// Get the SDK configuration for this user. /// /// Note: This method should be called only after SDK has been initialized. /// public static SdkConfiguration GetSdkConfiguration() { return SdkConfiguration.CreateEmpty(); } /// /// Set whether or not user has provided consent for information sharing with AppLovin and other providers. /// /// true if the user has provided consent for information sharing with AppLovin. false by default. public static void SetHasUserConsent(bool hasUserConsent) { _hasUserConsent = hasUserConsent; _isUserConsentSet = true; } /// /// Check if user has provided consent for information sharing with AppLovin and other providers. /// /// true if user has provided consent for information sharing. false if the user declined to share information or the consent value has not been set . public static bool HasUserConsent() { return _hasUserConsent; } /// /// Check if user has set consent for information sharing. /// /// true if user has set a value of consent for information sharing. public static bool IsUserConsentSet() { return _isUserConsentSet; } /// /// Mark user as age restricted (i.e. under 16). /// /// true if the user is age restricted (i.e. under 16). public static void SetIsAgeRestrictedUser(bool isAgeRestrictedUser) { _isAgeRestrictedUser = isAgeRestrictedUser; _isAgeRestrictedUserSet = true; } /// /// Check if user is age restricted. /// /// true if the user is age-restricted. false if the user is not age-restricted or the age-restriction has not been set. public static bool IsAgeRestrictedUser() { return _isAgeRestrictedUser; } /// /// Check if user set its age restricted settings. /// /// true if user has set its age restricted settings. public static bool IsAgeRestrictedUserSet() { return _isAgeRestrictedUserSet; } /// /// Set whether or not user has opted out of the sale of their personal information. /// /// true if the user has opted out of the sale of their personal information. public static void SetDoNotSell(bool doNotSell) { _doNotSell = doNotSell; _isDoNotSellSet = true; } /// /// Check if the user has opted out of the sale of their personal information. /// /// true if the user has opted out of the sale of their personal information. false if the user opted in to the sell of their personal information or the value has not been set . public static bool IsDoNotSell() { return _doNotSell; } /// /// Check if the user has set the option to sell their personal information. /// /// true if user has chosen an option to sell their personal information. public static bool IsDoNotSellSet() { return _isDoNotSellSet; } #endregion #region Banners /// /// Create a new banner. /// /// Ad unit identifier of the banner to create. Must not be null. /// Banner position. Must not be null. public static void CreateBanner(string adUnitIdentifier, BannerPosition bannerPosition) { ValidateAdUnitIdentifier(adUnitIdentifier, "create banner"); RequestAdUnit(adUnitIdentifier); if (_showStubAds && !StubBanners.ContainsKey(adUnitIdentifier)) { CreateStubBanner(adUnitIdentifier, bannerPosition); } ExecuteWithDelay(1f, () => { var eventProps = Json.Serialize(CreateBaseEventPropsDictionary("OnBannerAdLoadedEvent", adUnitIdentifier)); MaxSdkCallbacks.ForwardEvent(eventProps); }); } /// /// Create a new banner with a custom position. /// /// Ad unit identifier of the banner to create. Must not be null. /// The X coordinate (horizontal position) of the banner relative to the top left corner of the screen. /// The Y coordinate (vertical position) of the banner relative to the top left corner of the screen. /// /// The banner is placed within the safe area of the screen. You can use this to get the absolute position of the banner on screen. /// public static void CreateBanner(string adUnitIdentifier, float x, float y) { ValidateAdUnitIdentifier(adUnitIdentifier, "create banner"); RequestAdUnit(adUnitIdentifier); // TODO: Add stub ads support } private static void CreateStubBanner(string adUnitIdentifier, BannerPosition bannerPosition) { #if UNITY_EDITOR // Only support BottomCenter and TopCenter for now var bannerPrefabName = bannerPosition == BannerPosition.BottomCenter ? "BannerBottom" : "BannerTop"; var prefabPath = MaxSdkUtils.GetAssetPathForExportPath("MaxSdk/Prefabs/" + bannerPrefabName + ".prefab"); var bannerPrefab = AssetDatabase.LoadAssetAtPath(prefabPath); var stubBanner = Object.Instantiate(bannerPrefab, Vector3.zero, Quaternion.identity); stubBanner.SetActive(false); // Hidden by default Object.DontDestroyOnLoad(stubBanner); var bannerText = stubBanner.GetComponentInChildren(); bannerText.text += ":\n" + adUnitIdentifier; StubBanners.Add(adUnitIdentifier, stubBanner); #endif } /// /// Load a new banner ad. /// NOTE: The method loads the first banner ad and initiates an automated banner refresh process. /// You only need to call this method if you pause banner refresh. /// /// Ad unit identifier of the banner to load. Must not be null. public static void LoadBanner(string adUnitIdentifier) { ValidateAdUnitIdentifier(adUnitIdentifier, "load banner"); ExecuteWithDelay(1f, () => { var eventProps = Json.Serialize(CreateBaseEventPropsDictionary("OnBannerAdLoadedEvent", adUnitIdentifier)); MaxSdkCallbacks.ForwardEvent(eventProps); }); } /// /// Set the banner placement for an ad unit identifier to tie the future ad events to. /// /// Ad unit identifier of the banner to set the placement for. Must not be null. /// Placement to set public static void SetBannerPlacement(string adUnitIdentifier, string placement) { MaxSdkLogger.UserDebug("Setting banner placement to '" + placement + "' for ad unit id '" + adUnitIdentifier + "'"); } /// /// Starts or resumes auto-refreshing of the banner for the given ad unit identifier. /// /// Ad unit identifier of the banner for which to start auto-refresh. Must not be null. public static void StartBannerAutoRefresh(string adUnitIdentifier) { MaxSdkLogger.UserDebug("Starting banner auto refresh."); } /// /// Pauses auto-refreshing of the banner for the given ad unit identifier. /// /// Ad unit identifier of the banner for which to stop auto-refresh. Must not be null. public static void StopBannerAutoRefresh(string adUnitIdentifier) { MaxSdkLogger.UserDebug("Stopping banner auto refresh."); } /// /// Updates the position of the banner to the new position provided. /// /// The ad unit identifier of the banner for which to update the position. Must not be null. /// A new position for the banner. Must not be null. public static void UpdateBannerPosition(string adUnitIdentifier, BannerPosition bannerPosition) { Debug.Log("[AppLovin MAX] Updating banner position to '" + bannerPosition + "' for ad unit id '" + adUnitIdentifier + "'"); } /// /// Updates the position of the banner to the new coordinates provided. /// /// The ad unit identifier of the banner for which to update the position. Must not be null. /// The X coordinate (horizontal position) of the banner relative to the top left corner of the screen. /// The Y coordinate (vertical position) of the banner relative to the top left corner of the screen. /// /// The banner is placed within the safe area of the screen. You can use this to get the absolute position of the banner on screen. /// public static void UpdateBannerPosition(string adUnitIdentifier, float x, float y) { MaxSdkLogger.UserDebug("Updating banner position to '(" + x + "," + y + ")"); } /// /// Overrides the width of the banner in points/dp. /// /// The ad unit identifier of the banner for which to override the width for. Must not be null. /// The desired width of the banner in points/dp public static void SetBannerWidth(string adUnitIdentifier, float width) { // NOTE: Will implement in a future release Debug.Log("[AppLovin MAX] Set banner width to '" + width + "' for ad unit id '" + adUnitIdentifier + "'"); } /// /// Show banner at a position determined by the 'CreateBanner' call. /// /// Ad unit identifier of the banner to show. Must not be null. public static void ShowBanner(string adUnitIdentifier) { ValidateAdUnitIdentifier(adUnitIdentifier, "show banner"); if (!IsAdUnitRequested(adUnitIdentifier)) { MaxSdkLogger.UserWarning("Banner '" + adUnitIdentifier + "' was not created, can not show it"); } else { GameObject stubBanner; if (StubBanners.TryGetValue(adUnitIdentifier, out stubBanner)) { stubBanner.SetActive(true); } } } /// /// Remove banner from the ad view and destroy it. /// /// Ad unit identifier of the banner to destroy. Must not be null. public static void DestroyBanner(string adUnitIdentifier) { ValidateAdUnitIdentifier(adUnitIdentifier, "destroy banner"); GameObject stubBanner; if (StubBanners.TryGetValue(adUnitIdentifier, out stubBanner)) { Object.Destroy(stubBanner); StubBanners.Remove(adUnitIdentifier); } } /// /// Hide banner. /// /// Ad unit identifier of the banner to hide. Must not be null. public static void HideBanner(string adUnitIdentifier) { ValidateAdUnitIdentifier(adUnitIdentifier, "hide banner"); GameObject stubBanner; if (StubBanners.TryGetValue(adUnitIdentifier, out stubBanner)) { stubBanner.SetActive(false); } } /// /// Set non-transparent background color for banners to be fully functional. /// /// Ad unit identifier of the banner to set background color for. Must not be null. /// A background color to set for the ad. Must not be null. public static void SetBannerBackgroundColor(string adUnitIdentifier, Color color) { ValidateAdUnitIdentifier(adUnitIdentifier, "set background color"); GameObject stubBanner; if (StubBanners.TryGetValue(adUnitIdentifier, out stubBanner)) { stubBanner.GetComponentInChildren().color = color; } } /// /// Set an extra parameter for the banner ad. /// /// Ad unit identifier of the banner to set the extra parameter for. Must not be null. /// The key for the extra parameter. Must not be null. /// The value for the extra parameter. public static void SetBannerExtraParameter(string adUnitIdentifier, string key, string value) { ValidateAdUnitIdentifier(adUnitIdentifier, "set banner extra parameter"); } /// /// Set a local extra parameter for the banner ad. /// /// Ad unit identifier of the banner to set the local extra parameter for. Must not be null. /// The key for the local extra parameter. Must not be null. /// The value for the local extra parameter. public static void SetBannerLocalExtraParameter(string adUnitIdentifier, string key, object value) { ValidateAdUnitIdentifier(adUnitIdentifier, "set banner local extra parameter"); } /// /// The custom data to tie the showing banner ad to, for ILRD and rewarded postbacks via the {CUSTOM_DATA} macro. Maximum size is 8KB. /// /// Banner ad unit identifier of the banner to set the custom data for. Must not be null. /// The custom data to be set. public static void SetBannerCustomData(string adUnitIdentifier, string customData) { ValidateAdUnitIdentifier(adUnitIdentifier, "set banner custom data"); } /// /// The banner position on the screen. When setting the banner position via or , /// the banner is placed within the safe area of the screen. This returns the absolute position of the banner on screen. /// /// Ad unit identifier of the banner for which to get the position on screen. Must not be null. /// A representing the banner position on screen. public static Rect GetBannerLayout(string adUnitIdentifier) { ValidateAdUnitIdentifier(adUnitIdentifier, "get banner layout"); return Rect.zero; } #endregion #region MRECs /// /// Create a new MREC. /// /// Ad unit identifier of the MREC to create. Must not be null. /// MREC position. Must not be null. public static void CreateMRec(string adUnitIdentifier, AdViewPosition mrecPosition) { ValidateAdUnitIdentifier(adUnitIdentifier, "create MREC"); RequestAdUnit(adUnitIdentifier); ExecuteWithDelay(1f, () => { var eventProps = Json.Serialize(CreateBaseEventPropsDictionary("OnMRecAdLoadedEvent", adUnitIdentifier)); MaxSdkCallbacks.ForwardEvent(eventProps); }); } /// /// Create a new MREC with a custom position. /// /// Ad unit identifier of the MREC to create. Must not be null. /// The X coordinate (horizontal position) of the MREC relative to the top left corner of the screen. /// The Y coordinate (vertical position) of the MREC relative to the top left corner of the screen. /// /// The MREC is placed within the safe area of the screen. You can use this to get the absolute position Rect of the MREC on screen. /// public static void CreateMRec(string adUnitIdentifier, float x, float y) { ValidateAdUnitIdentifier(adUnitIdentifier, "create MREC"); RequestAdUnit(adUnitIdentifier); } /// /// Load a new MREC ad. /// NOTE: The method loads the first MREC ad and initiates an automated MREC refresh process. /// You only need to call this method if you pause MREC refresh. /// /// Ad unit identifier of the MREC to load. Must not be null. public static void LoadMRec(string adUnitIdentifier) { ValidateAdUnitIdentifier(adUnitIdentifier, "load MREC"); ExecuteWithDelay(1f, () => { var eventProps = Json.Serialize(CreateBaseEventPropsDictionary("OnMRecAdLoadedEvent", adUnitIdentifier)); MaxSdkCallbacks.ForwardEvent(eventProps); }); } /// /// Set the MREC placement for an ad unit identifier to tie the future ad events to. /// /// Ad unit identifier of the MREC to set the placement for. Must not be null. /// Placement to set public static void SetMRecPlacement(string adUnitIdentifier, string placement) { MaxSdkLogger.UserDebug("Setting MREC placement to '" + placement + "' for ad unit id '" + adUnitIdentifier + "'"); } /// /// Starts or resumes auto-refreshing of the MREC for the given ad unit identifier. /// /// Ad unit identifier of the MREC for which to start auto-refresh. Must not be null. public static void StartMRecAutoRefresh(string adUnitIdentifier) { MaxSdkLogger.UserDebug("Starting banner auto refresh."); } /// /// Pauses auto-refreshing of the MREC for the given ad unit identifier. /// /// Ad unit identifier of the MREC for which to stop auto-refresh. Must not be null. public static void StopMRecAutoRefresh(string adUnitIdentifier) { MaxSdkLogger.UserDebug("Stopping banner auto refresh."); } /// /// Updates the position of the MREC to the new position provided. /// /// The ad unit identifier of the MREC for which to update the position. Must not be null. /// A new position for the MREC. Must not be null. public static void UpdateMRecPosition(string adUnitIdentifier, AdViewPosition mrecPosition) { MaxSdkLogger.UserDebug("Updating MREC position to '" + mrecPosition + "' for ad unit id '" + adUnitIdentifier + "'"); } /// /// Updates the position of the MREC to the new coordinates provided. /// /// The ad unit identifier of the MREC for which to update the position. Must not be null. /// The X coordinate (horizontal position) of the MREC relative to the top left corner of the screen. /// The Y coordinate (vertical position) of the MREC relative to the top left corner of the screen. /// /// The MREC is placed within the safe area of the screen. You can use this to get the absolute position Rect of the MREC on screen. /// public static void UpdateMRecPosition(string adUnitIdentifier, float x, float y) { MaxSdkLogger.UserDebug("Updating MREC position to '(" + x + "," + y + ")"); } /// /// Show MREC at a position determined by the 'CreateMRec' call. /// /// Ad unit identifier of the MREC to show. Must not be null. public static void ShowMRec(string adUnitIdentifier) { ValidateAdUnitIdentifier(adUnitIdentifier, "show MREC"); if (!IsAdUnitRequested(adUnitIdentifier)) { MaxSdkLogger.UserWarning("MREC '" + adUnitIdentifier + "' was not created, can not show it"); } } /// /// Remove MREC from the ad view and destroy it. /// /// Ad unit identifier of the MREC to destroy. Must not be null. public static void DestroyMRec(string adUnitIdentifier) { ValidateAdUnitIdentifier(adUnitIdentifier, "destroy MREC"); } /// /// Hide MREC. /// /// Ad unit identifier of the MREC to hide. Must not be null. public static void HideMRec(string adUnitIdentifier) { ValidateAdUnitIdentifier(adUnitIdentifier, "hide MREC"); } /// /// Set an extra parameter for the MREC ad. /// /// Ad unit identifier of the MREC to set the extra parameter for. Must not be null. /// The key for the extra parameter. Must not be null. /// The value for the extra parameter. public static void SetMRecExtraParameter(string adUnitIdentifier, string key, string value) { ValidateAdUnitIdentifier(adUnitIdentifier, "set MREC extra parameter"); } /// /// Set a local extra parameter for the MREC ad. /// /// Ad unit identifier of the MREC to set the local extra parameter for. Must not be null. /// The key for the local extra parameter. Must not be null. /// The value for the local extra parameter. public static void SetMRecLocalExtraParameter(string adUnitIdentifier, string key, object value) { ValidateAdUnitIdentifier(adUnitIdentifier, "set MREC local extra parameter"); } /// /// The custom data to tie the showing MREC ad to, for ILRD and rewarded postbacks via the {CUSTOM_DATA} macro. Maximum size is 8KB. /// /// MREC Ad unit identifier of the banner to set the custom data for. Must not be null. /// The custom data to be set. public static void SetMRecCustomData(string adUnitIdentifier, string customData) { ValidateAdUnitIdentifier(adUnitIdentifier, "set MREC custom data"); } /// /// The MREC position on the screen. When setting the MREC position via or , /// the MREC is placed within the safe area of the screen. This returns the absolute position of the MREC on screen. /// /// Ad unit identifier of the MREC for which to get the position on screen. Must not be null. /// A representing the banner position on screen. public static Rect GetMRecLayout(string adUnitIdentifier) { ValidateAdUnitIdentifier(adUnitIdentifier, "get MREC layout"); return Rect.zero; } #endregion #region Interstitials /// /// Start loading an interstitial. /// /// Ad unit identifier of the interstitial to load public static void LoadInterstitial(string adUnitIdentifier) { ValidateAdUnitIdentifier(adUnitIdentifier, "load interstitial"); RequestAdUnit(adUnitIdentifier); ExecuteWithDelay(1f, () => { AddReadyAdUnit(adUnitIdentifier); var eventProps = Json.Serialize(CreateBaseEventPropsDictionary("OnInterstitialLoadedEvent", adUnitIdentifier)); MaxSdkCallbacks.ForwardEvent(eventProps); }); } /// /// Check if interstitial ad is loaded and ready to be displayed. /// /// Ad unit identifier of the interstitial to load /// True if the ad is ready to be displayed public static bool IsInterstitialReady(string adUnitIdentifier) { ValidateAdUnitIdentifier(adUnitIdentifier, "check interstitial loaded"); if (!IsAdUnitRequested(adUnitIdentifier)) { MaxSdkLogger.UserWarning("Interstitial '" + adUnitIdentifier + "' was not requested, can not check if it is loaded"); return false; } return IsAdUnitReady(adUnitIdentifier); } /// /// Present loaded interstitial for a given placement to tie ad events to. Note: if the interstitial is not ready to be displayed nothing will happen. /// /// Ad unit identifier of the interstitial to load /// The placement to tie the showing ad's events to /// The custom data to tie the showing ad's events to. Maximum size is 8KB. public static void ShowInterstitial(string adUnitIdentifier, string placement = null, string customData = null) { ValidateAdUnitIdentifier(adUnitIdentifier, "show interstitial"); if (!IsAdUnitRequested(adUnitIdentifier)) { MaxSdkLogger.UserWarning( "Interstitial '" + adUnitIdentifier + "' was not requested, can not show it"); return; } if (!IsInterstitialReady(adUnitIdentifier)) { MaxSdkLogger.UserWarning("Interstitial '" + adUnitIdentifier + "' is not ready, please check IsInterstitialReady() before showing."); return; } RemoveReadyAdUnit(adUnitIdentifier); if (_showStubAds) { ShowStubInterstitial(adUnitIdentifier); } } private static void ShowStubInterstitial(string adUnitIdentifier) { #if UNITY_EDITOR var prefabPath = MaxSdkUtils.GetAssetPathForExportPath("MaxSdk/Prefabs/Interstitial.prefab"); var interstitialPrefab = AssetDatabase.LoadAssetAtPath(prefabPath); var stubInterstitial = Object.Instantiate(interstitialPrefab, Vector3.zero, Quaternion.identity); var interstitialText = GameObject.Find("MaxInterstitialTitle").GetComponent(); var closeButton = GameObject.Find("MaxInterstitialCloseButton").GetComponent