コード例 #1
0
ファイル: BuildTool.cs プロジェクト: HuyLM/AnimalFight
 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
ファイル: BuildTool.cs プロジェクト: HuyLM/AnimalFight
        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;
            }
        }
コード例 #3
0
ファイル: BuildTool.cs プロジェクト: HuyLM/AnimalFight
        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);
            }
        }