Пример #1
0
 public static void ValidModuleScriptingDefine(bool isDevelop, BuildConfig.CustomBuildTarget buildTarget, BuildConfig buildConfig, BuildTargetGroup buildTargetGroup)
 {
     if (buildConfig != null)
     {
         var defines = GetBuildDefines(isDevelop, buildTarget, buildConfig, buildTargetGroup);
         ScriptingDefine.SaveScriptingDefineSymbolsForGroup(buildTargetGroup, defines.ToArray());
     }
     else
     {
         Logs.LogError("buildConfig is null please check");
     }
 }
Пример #2
0
        public static List <string> GetBuildDefines(bool isDevelop, BuildConfig.CustomBuildTarget buildTarget, BuildConfig buildConfig, BuildTargetGroup buildTargetGroup)
        {
            string defineBuild = PlayerSettings.GetScriptingDefineSymbolsForGroup(buildTargetGroup);
            var    defines     = ExtractDefineNames(defineBuild);

#if ADS_ENABLE
            var adsConfig = AdsEditor.LoadAdsConfigResouce();
            if (adsConfig == null)
            {
                throw new BuildException("Please Set up ads api before build production version");
            }
            else
            {
                AdsEditor.ValidUnityAdsScriptingDefine(adsConfig, buildTargetGroup);
            }
#endif

            ScriptingDefine.EnableScriptingDefineFlag(isDevelop, Logs.EnableLogsString, defines);
            ScriptingDefine.EnableScriptingDefineFlag(!isDevelop, ProductionBuildString, defines);
            ScriptingDefine.EnableScriptingDefineFlag(buildConfig.enableAds, AdsEnableString, defines);
            ScriptingDefine.EnableScriptingDefineFlag(buildConfig.enableFirebase, FirebaseEnableString, defines);

            ScriptingDefine.EnableScriptingDefineFlag(buildConfig.enableIap, IapEnableString, defines);
            if (buildConfig.scriptingDefines != null)
            {
                foreach (var variable in buildConfig.scriptingDefines)
                {
                    var enableTargetBuild = (variable.target & buildTarget) == buildTarget;
                    if (isDevelop)
                    {
                        ScriptingDefine.EnableScriptingDefineFlag(enableTargetBuild && variable.develop, variable.key,
                                                                  defines);
                    }
                    else
                    {
                        ScriptingDefine.EnableScriptingDefineFlag(enableTargetBuild && variable.release, variable.key,
                                                                  defines);
                    }
                }
            }

            return(defines);
        }
Пример #3
0
        private void PrintDefines(BuildConfig.CustomBuildTarget buildTarget, bool isDevelop)
        {
            EditorGUILayout.BeginVertical("Box");
            var label = buildTarget + (isDevelop ? " [Develop]" : " [Release]");

            EditorGUILayout.LabelField(label + (isDevelop == Build.IsDebug ? " [CURRENT]" : ""));
            var buildDefines =
                BuildTool.GetBuildDefines(isDevelop, buildTarget, buildConfig, ScriptingDefine.GetBuildTargetGroup());

            if (buildDefines != null)
            {
                using (new EditorGUI.DisabledGroupScope(true)) {
                    foreach (var buildDefine in buildDefines)
                    {
                        EditorGUILayout.LabelField(buildDefine);
                    }
                }
            }

            EditorGUILayout.EndVertical();
        }
Пример #4
0
        private void ModuleConfigTab()
        {
            EditorGUILayout.PropertyField(serializedObject.FindProperty("enableIap"));
            EditorGUILayout.PropertyField(serializedObject.FindProperty("enableAds"));
            EditorGUILayout.PropertyField(serializedObject.FindProperty("enableFirebase"));
            EditorGUILayout.Separator();
            reorderableList.DoLayoutList();

            if (GUILayout.Button("Save"))
            {
                BuildTool.ValidModuleScriptingDefine(Build.IsDebug,
                                                     BuildTool.GetFromUnityBuildTarget(ScriptingDefine.GetBuildTargetGroup()), buildConfig,
                                                     ScriptingDefine.GetBuildTargetGroup());
            }

            GUILayout.Space(20);
            this.BeginScrollView(ref configScrollPos, () => {
                currentTargetGroupTab = GUILayout.Toolbar(currentTargetGroupTab, targetGroupLabels);
                switch (currentTargetGroupTab)
                {
                case 0:
                    EditorGUILayout.BeginHorizontal();
                    PrintDefines(BuildConfig.CustomBuildTarget.Android, true);
                    PrintDefines(BuildConfig.CustomBuildTarget.Android, false);
                    EditorGUILayout.EndHorizontal();
                    break;

                case 1:
                    EditorGUILayout.BeginHorizontal();
                    PrintDefines(BuildConfig.CustomBuildTarget.iOS, true);
                    PrintDefines(BuildConfig.CustomBuildTarget.iOS, false);
                    EditorGUILayout.EndHorizontal();
                    break;
                }
            });

            serializedObject.ApplyModifiedProperties();
        }
Пример #5
0
        public static string BuildIos(BuildConfig buildConfig, BuildConfig.Options options)
        {
            SwitchToiOS();
            var buildTargetGroup = BuildTargetGroup.iOS;

#if ADS_ENABLE
            AdsConfig.ApiInfo adsConfig = AdsSetting.LoadIosConfigFromResouceFolder();

            if (!options.isDevelop && adsConfig == null && buildConfig.enableAds)
            {
                throw new BuildException("Please set up ads api before build production version");
            }

            if (adsConfig != null)
            {
                AdsEditor.SetPlayerSetingBuilTargetGroup(adsConfig, buildTargetGroup);
            }
#endif

            ValidModuleScriptingDefine(options.isDevelop, BuildConfig.CustomBuildTarget.iOS, buildConfig, buildTargetGroup);
            var defineBuild = PlayerSettings.GetScriptingDefineSymbolsForGroup(buildTargetGroup);
            var productName = PlayerSettings.productName;
            PlayerSettings.bundleVersion             = buildConfig.BuildVersion;
            PlayerSettings.iOS.targetDevice          = buildConfig.iOSTargetDevice;
            PlayerSettings.iOS.targetOSVersionString = buildConfig.iOSTargetOSVersion;
            PlayerSettings.iOS.sdkVersion            = buildConfig.iOSSdkVersion;

            var splashBackground = buildConfig.iOsSplashBackground;
            var splashLogo       = buildConfig.iOsSplashLogo;
            var icon             = buildConfig.iOSIcon;
            SetUpSplashAndIcon(splashBackground, splashLogo, icon, buildTargetGroup);

            var isDevelop    = options.isDevelop;
            var buildOptions = isDevelop ? buildConfig.developOptions : buildConfig.productionOptions;


            if (options.autorun)
            {
                buildOptions |= BuildOptions.AutoRunPlayer;
            }

            var locationPathName        = Path.Combine(GetBuildFolder(), isDevelop ? "DevIos" : "ReleaseIos");
            var scriptingImplementation = PlayerSettings.GetScriptingBackend(buildTargetGroup);

            if (options.isDevelop)
            {
                PlayerSettings.productName = "Dev " + productName;
            }
            else if (buildConfig.iOsIl2CppForRelease)
            {
                PlayerSettings.SetScriptingBackend(buildTargetGroup, ScriptingImplementation.IL2CPP);
            }

            EditorUserBuildSettings.development = options.isDevelop;

            try {
                BuildPipeline.BuildPlayer(GetScenePaths(), locationPathName, BuildTarget.iOS, buildOptions);
                if (options.autoOpen)
                {
                    EditorUtility.RevealInFinder(locationPathName);
                }

                return(locationPathName);
            }
            catch (Exception e) {
                throw e;
            }
            finally {
                ScriptingDefine.SaveScriptingDefineSymbolsForGroup(buildTargetGroup, defineBuild);
                PlayerSettings.SetScriptingBackend(buildTargetGroup, scriptingImplementation);

                PlayerSettings.productName = productName;
            }
        }
Пример #6
0
        private static string BuildAndroid(BuildConfig buildConfig, string suffix, BuildConfig.Options options, OsBuild osBuild)
        {
            CheckKeyStore(buildConfig);
            var buildTargetGroup = BuildTargetGroup.Android;

#if ADS_ENABLE
            AdsConfig.ApiInfo config = AdsSetting.LoadAndroidConfigFromResouceFolder();

            if (config != null)
            {
                AdsEditor.SetPlayerSetingBuilTargetGroup(config, buildTargetGroup);
            }

            if (!options.isDevelop && config == null && buildConfig.enableAds)
            {
                throw new BuildException("Please Set up ads api before build production version");
            }
#endif

            ValidModuleScriptingDefine(options.isDevelop, BuildConfig.CustomBuildTarget.Android, buildConfig, buildTargetGroup);
            var defineBuild = PlayerSettings.GetScriptingDefineSymbolsForGroup(buildTargetGroup);
            var productName = PlayerSettings.productName;
            PlayerSettings.bundleVersion                    = buildConfig.BuildVersion;
            PlayerSettings.Android.bundleVersionCode        = buildConfig.BuildVerCode;
            PlayerSettings.Android.preferredInstallLocation = AndroidPreferredInstallLocation.Auto;
            PlayerSettings.Android.forceSDCardPermission    = false;

            var splashBackground = buildConfig.androidSplashBackground;
            var splashLogo       = buildConfig.androidSplashLogo;
            var icon             = buildConfig.androidIcon;

            SetUpSplashAndIcon(splashBackground, splashLogo, icon, buildTargetGroup);

            var buildOptions = options.isDevelop ? buildConfig.developOptions : buildConfig.productionOptions;

            if (options.autorun)
            {
                buildOptions |= BuildOptions.AutoRunPlayer;
            }

            var filename = GetFileName(suffix);
            filename = (options.isDevelop ? "dev_" : "release_") + filename;
            Debug.LogFormat("Prepare for build {0}", filename);

            var scriptingImplementation = PlayerSettings.GetScriptingBackend(buildTargetGroup);

            if (options.isDevelop && options.isBuildAPK)
            {
                PlayerSettings.Android.targetArchitectures = AndroidArchitecture.ARMv7;
            }
            else
            {
                if (buildConfig.AndroidIl2CppForRelease)
                {
                    PlayerSettings.SetScriptingBackend(buildTargetGroup, ScriptingImplementation.IL2CPP);
                }
                SetupAchitecture(buildConfig);
            }

            EditorUserBuildSettings.development    = options.isDevelop;
            EditorUserBuildSettings.buildAppBundle = !options.isBuildAPK;

            var locationPathName = Path.Combine(GetBuildFolder(), filename);
            try {
                BuildPipeline.BuildPlayer(GetScenePaths(), locationPathName, BuildTarget.Android, buildOptions);
                if (options.autoOpen)
                {
                    EditorUtility.RevealInFinder(locationPathName);
                }

                return(locationPathName);
            }
            catch (Exception e) {
                throw e;
            }
            finally {
                PlayerSettings.productName = productName;
                PlayerSettings.SetScriptingBackend(buildTargetGroup, scriptingImplementation);
                ScriptingDefine.SaveScriptingDefineSymbolsForGroup(buildTargetGroup, defineBuild);
            }
        }