Esempio n. 1
0
        private void OnEnable()
        {
            SetSettingsPlatform();

            InitMainProperties(serializedObject);
            InitEditorSettingsProperties();

            allowedPackageUpdate = Utils.IsPackageExist(Utils.packageName);

            dependencyManager = DependencyManager.Create(platform, ( Audience )audienceTaggedProp.enumValueIndex, true);

            HandleDeprecatedComponents();
            InitEDM4U();
            InitEnvironmentDetails();

            EditorApplication.delayCall += () =>
            {
                newCASVersion = Utils.GetNewVersionOrNull(Utils.gitUnityRepo, MobileAds.wrapperVersion, false);
            };
        }
        public static void ConfigureProject(BuildTarget target, CASEditorSettings editorSettings)
        {
            if (target != BuildTarget.Android && target != BuildTarget.iOS)
            {
                return;
            }

            var settings = Utils.GetSettingsAsset(target, false);

            if (!settings)
            {
                Utils.StopBuildWithMessage("Settings asset not found. Please use menu Assets > CleverAdsSolutions > Settings " +
                                           "to create and set settings for build.", target);
            }

            var deps = DependencyManager.Create(target, Audience.Mixed, true);

            if (!Application.isBatchMode)
            {
                var newCASVersion = Utils.GetNewVersionOrNull(Utils.gitUnityRepo, MobileAds.wrapperVersion, false);
                if (newCASVersion != null)
                {
                    Utils.DialogOrCancelBuild("There is a new version " + newCASVersion + " of the CAS Unity available for update.", target);
                }

                if (deps != null)
                {
                    if (!deps.installedAny)
                    {
                        Utils.StopBuildWithMessage("Dependencies of native SDK were not found. " +
                                                   "Please use 'Assets > CleverAdsSolutions > Settings' menu to integrate solutions or any SDK separately.", target);
                    }

                    if (deps.IsNewerVersionFound())
                    {
                        Utils.DialogOrCancelBuild("There is a new versions of the native dependencies available for update." +
                                                  "Please use 'Assets > CleverAdsSolutions >Settings' menu to update.", target);
                    }
                }
            }

            if (settings.managersCount == 0 || string.IsNullOrEmpty(settings.GetManagerId(0)))
            {
                StopBuildIDNotFound(target);
            }

            string admobAppId = UpdateRemoteSettingsAndGetAppId(settings, target, deps);

            if (target == BuildTarget.Android)
            {
                ConfigureAndroid(settings, editorSettings, admobAppId);
            }
            else if (target == BuildTarget.iOS)
            {
                ConfigureIOS();
            }

#pragma warning disable CS0618 // Type or member is obsolete
            // Use directrly property to avoid Debug build
            if (settings.testAdMode && !EditorUserBuildSettings.development)
            {
                Debug.LogWarning(Utils.logTag + "Test Ads Mode enabled! Make sure the build is for testing purposes only!\n" +
                                 "Use 'Assets > CleverAdsSolutions > Settings' menu to disable Test Ad Mode.");
            }
            else
            {
                Debug.Log(Utils.logTag + "Project configuration completed");
            }
#pragma warning restore CS0618 // Type or member is obsolete
        }