示例#1
0
        internal void Init(DependencyManager mediation, BuildTarget platform, bool updateContaines)
        {
            var path = Utils.GetDependencyPath(name, platform);

            if (File.Exists(path))
            {
                var          dependency = File.ReadAllText(path);
                const string line       = "version=\"";
                var          beginIndex = dependency.IndexOf(line, 45);
                if (beginIndex > 0)
                {
                    beginIndex      += line.Length;
                    installedVersion = dependency.Substring(beginIndex, dependency.IndexOf('\"', beginIndex) - beginIndex);
                    try
                    {
                        //var currVer = new Version( installedVersion );
                        //var targetVer = new Version( version );
                        //isNewer = currVer < targetVer;
                        isNewer = installedVersion != version;
                    }
                    catch
                    {
                        isNewer = true;
                    }
                    mediation.installedAny = true;
                }

                if (updateContaines)
                {
                    for (int i = 0; i < contains.Length; i++)
                    {
                        var item = mediation.Find(contains[i]);
                        if (item != null)
                        {
                            item.locked = true;
                        }
                    }

                    var requiredItem = mediation.Find(require);
                    if (requiredItem != null)
                    {
                        requiredItem.isRequired = true;
                    }
                }
            }
        }
示例#2
0
        private static void UpdateGADAppId(PlistDocument plist, CASInitSettings initSettings, DependencyManager deps)
        {
            if (!initSettings)
            {
                return;
            }
            #region Read Admob App ID from CAS Settings
            bool admobAppIdRequired = deps == null;
            if (deps != null)
            {
                var admobDep = deps.Find(AdNetwork.GoogleAds);
                if (admobDep != null)
                {
                    admobAppIdRequired = admobDep.IsInstalled();
                }
            }

            string admobAppId = null;
            if (initSettings.managersCount > 0)
            {
                string settingsPath = CASEditorUtils.GetNativeSettingsPath(BuildTarget.iOS, initSettings.GetManagerId(0));
                if (File.Exists(settingsPath))
                {
                    try
                    {
                        admobAppId = CASEditorUtils.GetAdmobAppIdFromJson(File.ReadAllText(settingsPath));
                    }
                    catch (Exception e)
                    {
                        if (!initSettings.IsTestAdMode() && admobAppIdRequired)
                        {
                            CASEditorUtils.StopBuildWithMessage(e.ToString(), BuildTarget.iOS);
                        }
                    }
                }
            }
            if (string.IsNullOrEmpty(admobAppId) && initSettings.IsTestAdMode())
            {
                admobAppId = CASEditorUtils.iosAdmobSampleAppID;
            }

            #endregion

            if (!string.IsNullOrEmpty(admobAppId))
            {
                plist.root.SetString("GADApplicationIdentifier", admobAppId);
            }
        }
        public static string GetActiveMediationPattern(DependencyManager manager)
        {
            if (manager == null)
            {
                return("");
            }

            var networks = Enum.GetValues(typeof(AdNetwork));
            var result   = new char[networks.Length];

            for (int i = 0; i < networks.Length; i++)
            {
                var dependency = manager.Find(( AdNetwork )networks.GetValue(i));
                result[i] = (dependency != null && dependency.IsInstalled()) ? dependency.mediation : '0';
            }
            return(new string( result ));
        }
示例#4
0
        private void AppendSDK(BuildTarget platform, DependencyManager mediation, StringBuilder builder, bool allowAllTargets)
        {
            for (int i = 0; i < depsSDK.Count; i++)
            {
                if (allowAllTargets == depsSDK[i].addToAllTargets)
                {
                    AppendDependency(mediation, depsSDK[i], platform, builder);
                }
            }

            for (int i = 0; i < contains.Length; i++)
            {
                var item = mediation.Find(contains[i]);
                if (item != null)
                {
                    item.AppendSDK(platform, mediation, builder, allowAllTargets);
                }
            }
        }
示例#5
0
        public void ActivateDependencies(BuildTarget platform, DependencyManager mediation)
        {
            if (dependencies.Length == 0 && depsSDK.Count == 0)
            {
                Debug.LogError(Utils.logTag + name + " have no dependencies. Please try reimport CAS package.");
                return;
            }
            if (locked)
            {
                return;
            }

            string depTagName  = platform == BuildTarget.Android ? "androidPackage" : "iosPod";
            var    destination = Utils.GetDependencyPathOrDefault(name, platform);

            EditorUtility.DisplayProgressBar("Create dependency", destination, 0.2f);

            try
            {
                var builder = new StringBuilder();
                builder.AppendLine("<?xml version=\"1.0\" encoding=\"utf-8\"?>")
                .AppendLine("<dependencies>")
                .Append("  <").Append(depTagName).Append("s>").AppendLine();

                for (int i = 0; i < dependencies.Length; i++)
                {
                    AppendDependency(mediation, new SDK(dependencies[i], version), platform, builder);
                }

                // EDM4U have a bug.
                // Dependencies that will be added For All Targets must be at the end of the list of dependencies.
                // Otherwise, those dependencies that should not be for all targets will be tagged for all targets.
                AppendSDK(platform, mediation, builder, false);
                AppendSDK(platform, mediation, builder, true);

                builder.Append("  </").Append(depTagName).Append("s>").AppendLine()
                .AppendLine("</dependencies>");

                var replace = File.Exists(destination);
                if (!replace)
                {
                    var destDir = Path.GetDirectoryName(destination);
                    if (!Directory.Exists(destDir))
                    {
                        Directory.CreateDirectory(destDir);
                    }
                }

                File.WriteAllText(destination, builder.ToString());
                if (!replace)
                {
                    AssetDatabase.ImportAsset(destination);
                }

                Init(mediation, platform, true);
            }
            finally
            {
                EditorUtility.ClearProgressBar();
            }

            var requireItem = mediation.Find(require);

            if (requireItem != null)
            {
                requireItem.isRequired = true;
                if (!requireItem.IsInstalled())
                {
                    requireItem.ActivateDependencies(platform, mediation);
                }
            }
        }