private static void ShowStubRewardedInterstitialAd(string adUnitIdentifier) { #if UNITY_EDITOR var prefabPath = MaxSdkUtils.GetAssetPathForExportPath("MaxSdk/Prefabs/Rewarded.prefab"); var rewardedPrefab = AssetDatabase.LoadAssetAtPath <GameObject>(prefabPath); var stubRewardedAd = Object.Instantiate(rewardedPrefab, Vector3.zero, Quaternion.identity); var grantedReward = false; var rewardedTitle = GameObject.Find("MaxRewardTitle").GetComponent <Text>(); var rewardStatus = GameObject.Find("MaxRewardStatus").GetComponent <Text>(); var closeButton = GameObject.Find("MaxRewardedCloseButton").GetComponent <Button>(); var rewardButton = GameObject.Find("MaxRewardButton").GetComponent <Button>(); Object.DontDestroyOnLoad(stubRewardedAd); rewardedTitle.text = "MAX Rewarded Interstitial Ad:\n" + adUnitIdentifier; closeButton.onClick.AddListener(() => { if (grantedReward) { MaxSdkCallbacks.Instance.ForwardEvent("name=OnRewardedInterstitialAdReceivedRewardEvent\nadUnitId=" + adUnitIdentifier + "\nrewardLabel=coins\nrewardAmount=5"); } MaxSdkCallbacks.Instance.ForwardEvent("name=OnRewardedInterstitialAdHiddenEvent\nadUnitId=" + adUnitIdentifier); Object.Destroy(stubRewardedAd); }); rewardButton.onClick.AddListener(() => { grantedReward = true; rewardStatus.text = "Reward granted. Will send reward callback on ad close."; }); MaxSdkCallbacks.Instance.ForwardEvent("name=OnRewardedInterstitialAdDisplayedEvent\nadUnitId=" + adUnitIdentifier); #endif }
/// <summary> /// Updates the CurrentVersion fields for a given network data object. /// </summary> /// <param name="network">Network for which to update the current versions.</param> public static void UpdateCurrentVersions(Network network) { var dependencyFilePath = MaxSdkUtils.GetAssetPathForExportPath(network.DependenciesFilePath); var currentVersions = GetCurrentVersions(dependencyFilePath); network.CurrentVersions = currentVersions; // If AppLovin mediation plugin, get the version from MaxSdk and the latest and current version comparison. if (network.Name.Equals("APPLOVIN_NETWORK")) { network.CurrentVersions.Unity = MaxSdk.Version; var unityVersionComparison = MaxSdkUtils.CompareVersions(network.CurrentVersions.Unity, network.LatestVersions.Unity); var androidVersionComparison = MaxSdkUtils.CompareVersions(network.CurrentVersions.Android, network.LatestVersions.Android); var iosVersionComparison = MaxSdkUtils.CompareVersions(network.CurrentVersions.Ios, network.LatestVersions.Ios); // Overall version is same if all the current and latest (from db) versions are same. if (unityVersionComparison == VersionComparisonResult.Equal && androidVersionComparison == VersionComparisonResult.Equal && iosVersionComparison == VersionComparisonResult.Equal) { network.CurrentToLatestVersionComparisonResult = VersionComparisonResult.Equal; } // One of the installed versions is newer than the latest versions which means that the publisher is on a beta version. else if (unityVersionComparison == VersionComparisonResult.Greater || androidVersionComparison == VersionComparisonResult.Greater || iosVersionComparison == VersionComparisonResult.Greater) { network.CurrentToLatestVersionComparisonResult = VersionComparisonResult.Greater; } // We have a new version available if all Android, iOS and Unity has a newer version available in db. else { network.CurrentToLatestVersionComparisonResult = VersionComparisonResult.Lesser; } } // For all other mediation adapters, get the version comparison using their Unity versions. else { // If adapter is indeed installed, compare the current (installed) and the latest (from db) versions, so that we can determine if the publisher is on an older, current or a newer version of the adapter. // If the publisher is on a newer version of the adapter than the db version, that means they are on a beta version. if (!string.IsNullOrEmpty(currentVersions.Unity)) { network.CurrentToLatestVersionComparisonResult = MaxSdkUtils.CompareUnityMediationVersions(currentVersions.Unity, network.LatestVersions.Unity); } if (!string.IsNullOrEmpty(network.CurrentVersions.Unity) && AppLovinAutoUpdater.MinAdapterVersions.ContainsKey(network.Name)) { var comparisonResult = MaxSdkUtils.CompareUnityMediationVersions(network.CurrentVersions.Unity, AppLovinAutoUpdater.MinAdapterVersions[network.Name]); // Requires update if current version is lower than the min required version. network.RequiresUpdate = comparisonResult < 0; } else { // Reset value so that the Integration manager can hide the alert icon once adapter is updated. network.RequiresUpdate = false; } } }
private void Awake() { titleLabelStyle = new GUIStyle(EditorStyles.label) { fontSize = 14, fontStyle = FontStyle.Bold, fixedHeight = 20 }; headerLabelStyle = new GUIStyle(EditorStyles.label) { fontSize = 12, fontStyle = FontStyle.Bold, fixedHeight = 18 }; environmentValueStyle = new GUIStyle(EditorStyles.label) { alignment = TextAnchor.MiddleRight }; linkLabelStyle = new GUIStyle(EditorStyles.label) { wordWrap = true, normal = { textColor = Color.blue } }; wrapTextLabelStyle = new GUIStyle(EditorStyles.label) { wordWrap = true }; uninstallButtonStyle = new GUIStyle(EditorStyles.miniButton) { fixedWidth = 18, fixedHeight = 18, padding = new RectOffset(1, 1, 1, 1) }; // Load uninstall icon texture. var uninstallIconData = File.ReadAllBytes(MaxSdkUtils.GetAssetPathForExportPath(uninstallIconExportPath)); uninstallIcon = new Texture2D(0, 0, TextureFormat.RGBA32, false); // 1. Initial size doesn't matter here, will be automatically resized once the image asset is loaded. 2. Set mipChain to false, else the texture has a weird blurry effect. uninstallIcon.LoadImage(uninstallIconData); // Load alert icon texture. var alertIconData = File.ReadAllBytes(MaxSdkUtils.GetAssetPathForExportPath(alertIconExportPath)); alertIcon = new Texture2D(0, 0, TextureFormat.RGBA32, false); alertIcon.LoadImage(alertIconData); var pluginPath = Path.Combine(AppLovinIntegrationManager.PluginParentDirectory, "MaxSdk"); isPluginMoved = !AppLovinIntegrationManager.DefaultPluginExportPath.Equals(pluginPath); }
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 <GameObject>(prefabPath); var stubBanner = Object.Instantiate(bannerPrefab, Vector3.zero, Quaternion.identity); stubBanner.SetActive(false); // Hidden by default Object.DontDestroyOnLoad(stubBanner); var bannerText = stubBanner.GetComponentInChildren <Text>(); bannerText.text += ":\n" + adUnitIdentifier; StubBanners.Add(adUnitIdentifier, stubBanner); #endif }
private static void ShowStubInterstitial(string adUnitIdentifier) { #if UNITY_EDITOR var prefabPath = MaxSdkUtils.GetAssetPathForExportPath("MaxSdk/Prefabs/Interstitial.prefab"); var interstitialPrefab = AssetDatabase.LoadAssetAtPath <GameObject>(prefabPath); var stubInterstitial = Object.Instantiate(interstitialPrefab, Vector3.zero, Quaternion.identity); var interstitialText = GameObject.Find("MaxInterstitialTitle").GetComponent <Text>(); var closeButton = GameObject.Find("MaxInterstitialCloseButton").GetComponent <Button>(); interstitialText.text += ":\n" + adUnitIdentifier; closeButton.onClick.AddListener(() => { MaxSdkCallbacks.Instance.ForwardEvent("name=OnInterstitialHiddenEvent\nadUnitId=" + adUnitIdentifier); Object.Destroy(stubInterstitial); }); MaxSdkCallbacks.Instance.ForwardEvent("name=OnInterstitialDisplayedEvent\nadUnitId=" + adUnitIdentifier); #endif }