コード例 #1
0
        public void OnPreBuild(IStepLocator locator)
        {
#if UNITY_2020_1_OR_NEWER
            PlayerSettings.Android.minifyDebug   = EnableAndroidMinification;
            PlayerSettings.Android.minifyRelease = EnableAndroidMinification;
#else
            EditorUserBuildSettings.androidDebugMinification   = AndroidMinification;
            EditorUserBuildSettings.androidReleaseMinification = AndroidMinification;
#endif

            WriteProguardData();
        }
コード例 #2
0
        public virtual void OnPreBuild(IStepLocator locator)
        {
            if (locator.Get <BuildPipelineStep>().BuildTarget != BuildTarget.Android)
            {
                return;
            }

            // Прописываем BundleVersionCode.
            if (BundleVersionCode >= 0)
            {
                PlayerSettings.Android.bundleVersionCode = BundleVersionCode;
            }

            EditorUserBuildSettings.androidBuildSubtarget = AndroidBuildSubtarget;
            EditorUserBuildSettings.androidBuildSystem    = AndroidBuildSystem;
            EditorUserBuildSettings.buildAppBundle        = AndroidBuildAppBundle;

            PlayerSettings.Android.useCustomKeystore = UseCustomKeyStore;

            if (!string.IsNullOrEmpty(GradlePath))
            {
                AndroidExternalToolsSettings.gradlePath = GradlePath;
            }

            if (PlayerSettings.Android.useCustomKeystore)
            {
                PlayerSettings.Android.keystoreName = AndroidKeystore;
                if (!File.Exists(PlayerSettings.Android.keystoreName))
                {
                    throw new Exception("Keystore file '" + PlayerSettings.Android.keystoreName + "' is not exists!");
                }

                PlayerSettings.Android.keystorePass = AndroidKeystorePassword;
                if (string.IsNullOrEmpty(PlayerSettings.Android.keystorePass))
                {
                    throw new Exception("Keystore password not set!");
                }

                PlayerSettings.Android.keyaliasName = AndroidKeyalias;
                if (string.IsNullOrEmpty(PlayerSettings.Android.keyaliasName))
                {
                    throw new Exception("KeyAlias not set!");
                }

                PlayerSettings.Android.keyaliasPass = AndroidKeyaliasPassword;
                if (string.IsNullOrEmpty(PlayerSettings.Android.keyaliasPass))
                {
                    throw new Exception("KeyAlias password not set!");
                }
            }
        }
コード例 #3
0
        public virtual void OnPreBuild(IStepLocator locator)
        {
            var pipelineStep     = locator.Get <BuildPipelineStep>();
            var buildTarget      = pipelineStep.BuildTarget;
            var buildTargetGroup = BuildPipeline.GetBuildTargetGroup(buildTarget);

            var defines = CompilerDefinesUtils.ReadDefines()
                          .GetAllDefinesByPlatform(buildTargetGroup)
                          .Union(_addDefines)
                          .Except(_removeDefines)
                          .ToList();

            CompilerDefinesUtils.Write(defines, buildTargetGroup);
        }
コード例 #4
0
        public void OnPreBuild(IStepLocator locator)
        {
            if (locator.Get <BuildPipelineStep>().BuildTarget != BuildTarget.Android)
            {
                return;
            }

#if UNITY_2020_1_OR_NEWER
            PlayerSettings.Android.minifyDebug   = EnableAndroidMinification;
            PlayerSettings.Android.minifyRelease = EnableAndroidMinification;
#else
            EditorUserBuildSettings.androidDebugMinification   = AndroidMinification;
            EditorUserBuildSettings.androidReleaseMinification = AndroidMinification;
#endif

            WriteProguardData();
        }
コード例 #5
0
        public void OnPreBuild(IStepLocator locator)
        {
            var activeBuildTarget = locator.Get <BuildPipelineStep>().BuildTarget;

            if (activeBuildTarget != BuildTarget.Android && activeBuildTarget != BuildTarget.iOS)
            {
                return;
            }

            var activeBuildTargetGroup = BuildPipeline.GetBuildTargetGroup(activeBuildTarget);

            PlayerSettings.colorSpace             = ColorSpace;
            PlayerSettings.enableFrameTimingStats = EnableFrameTimingStats;
            PlayerSettings.SetUseDefaultGraphicsAPIs(activeBuildTarget, UseAutographicApi);
            PlayerSettings.SetMobileMTRendering(activeBuildTargetGroup, MultiThreadRendering);
            PlayerSettings.defaultInterfaceOrientation = InterfaceOrientation;
        }
コード例 #6
0
        /// <summary>
        /// Собирает информацию о билде и создает файл
        /// </summary>
        public virtual void OnPreBuild(IStepLocator locator)
        {
            var buildInfo = ScriptableObject.CreateInstance <BuildInfo>();

            buildInfo.BuildTimestamp = DateTime.Now;
#if UNITY_5_6_OR_NEWER
            buildInfo.BundleIdentifier = PlayerSettings.applicationIdentifier;
#else
            buildInfo.BundleIdentifier = PlayerSettings.bundleIdentifier;
#endif
            buildInfo.BundleVersion = !string.IsNullOrEmpty(PlayerSettings.bundleVersion) ? PlayerSettings.bundleVersion : "N/A";
            buildInfo.BuildDefines  = CompilerDefinesUtils.ReadDefines().GetAllDefinesByPlatform(EditorUserBuildSettings.selectedBuildTargetGroup).ToArray();

            // Если собирается на сервере CI ряд параметров берётся из переменных окружения.
            if (EnvVar("TEAMCITY_VERSION") != null)    //
            {
                buildInfo.MilestoneCodename = EnvVar("TEAMCITY_PROJECT_NAME") ?? "TEAMCITY N/A";
                buildInfo.BuildJob          = EnvVar("TEAMCITY_BUILDCONF_NAME") ?? "TEAMCITY N/A";
                buildInfo.SourceCodeVersion = EnvVar("BUILD_VCS_NUMBER") ?? "TEAMCITY N/A";
                if (!int.TryParse(EnvVar("BUILD_NUMBER") ?? "-1", out buildInfo.BuildNumber))
                {
                    buildInfo.BuildNumber = -1;
                }
            }
            else
            {
                buildInfo.MilestoneCodename = "N/A";
                buildInfo.BuildJob          = "N/A";
                buildInfo.SourceCodeVersion = "N/A";
                buildInfo.BuildNumber       = -1;
            }

            Debug.Log("BuildInfo: \n" + buildInfo);

            var directoryName = Path.GetDirectoryName(BuildInfoFullPath);
            if (!Directory.Exists(directoryName))
            {
                Directory.CreateDirectory(directoryName);
            }

            AssetDatabase.CreateAsset(buildInfo, BuildInfoFullPath);
            AssetDatabase.ImportAsset(BuildInfoFullPath, ImportAssetOptions.ForceUpdate | ImportAssetOptions.ForceSynchronousImport);
        }
コード例 #7
0
        public virtual void OnPreBuild(IStepLocator locator)
        {
            if (locator.Get <BuildPipelineStep>().BuildTarget != BuildTarget.WebGL)
            {
                return;
            }

            // Выставляем уровень логгирования для WebGL
            PlayerSettings.WebGL.exceptionSupport = WebGLExceptionSupport;

            if (!WebGLTemplate.StartsWith("PROJECT:") && !WebGLTemplate.StartsWith("APPLICATION:"))
            {
                throw new ArgumentException("webGLTemplate must start with 'PROJECT:' or 'APPLICATION:'");
            }

            PlayerSettings.WebGL.template = WebGLTemplate;

            PlayerSettings.defaultWebScreenHeight = DefaultWebScreenHeight;
            PlayerSettings.defaultWebScreenWidth  = DefaultWebScreenWidth;
        }
コード例 #8
0
        public virtual void OnPreBuild(IStepLocator locator)
        {
            if (locator.Get <BuildPipelineStep>().BuildTarget != BuildTarget.iOS)
            {
                return;
            }

            // билд для симулятора
            if (IosSimulator)
            {
                PlayerSettings.iOS.sdkVersion = iOSSdkVersion.SimulatorSDK;
                // recomended by Unity for IOS simulator
                PlayerSettings.SetUseDefaultGraphicsAPIs(BuildTarget.iOS, false);
                PlayerSettings.SetGraphicsAPIs(BuildTarget.iOS, new[] { GraphicsDeviceType.OpenGLES3, GraphicsDeviceType.OpenGLES2, GraphicsDeviceType.Metal });

                locator.Get <DefinesStep>().AddDefine("TARGET_OS_SIMULATOR");  // the same as Xcode sets for Simulator mode
            }

            PlayerSettings.iOS.appleDeveloperTeamID             = AppleTeamId;
            PlayerSettings.iOS.appleEnableAutomaticSigning      = AppleUseAutoSigning;
            PlayerSettings.iOS.iOSManualProvisioningProfileID   = AppleManualProvisionId;
            PlayerSettings.iOS.iOSManualProvisioningProfileType = AppleManualProvisionType;
        }
コード例 #9
0
        public virtual void OnPreBuild(IStepLocator locator)
        {
            var buildTarget = locator.Get <BuildPipelineStep>().BuildTarget;

            // Прописываем product name
            PlayerSettings.productName = ProductName;

            // Прописываем основную версию для всех платформ
            if (buildTarget == BuildTarget.iOS)
            {
                PlayerSettings.bundleVersion = BundleVersion.Substring(0, Math.Min(18, BundleVersion.Length));     // на iOS version ограничен 18-ю символами
            }
            else
            {
                PlayerSettings.bundleVersion = BundleVersion;
            }

            // Добавляем проверки на NullReferences и выход за границу массива при генерации IL2CPP
            PlayerSettings.SetAdditionalIl2CppArgs("--emit-null-checks --enable-array-bounds-check");

            // Отключаем лого
            PlayerSettings.SplashScreen.show          = ShowSplashScreen;
            PlayerSettings.SplashScreen.showUnityLogo = ShowUnityLogo;
        }
コード例 #10
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="flow"></param>
 /// <param name="map"></param>
 private void FindSteps(IFlow flow, IDictionary <string, IStep> map)
 {
     foreach (IState state in flow.GetStates())
     {
         var stepLocator = state as IStepLocator;
         if (stepLocator != null)
         {
             IStepLocator locator = stepLocator;
             foreach (string name in locator.GetStepNames())
             {
                 map.Add(name, locator.GetStep(name));
             }
         }
         else
         {
             var holder = state as IStepHolder;
             if (holder != null)
             {
                 IStep  step = holder.Step;
                 string name = step.Name;
                 _stepMap.Add(name, step);
             }
             else
             {
                 var flowHolder = state as IFlowHolder;
                 if (flowHolder != null)
                 {
                     foreach (IFlow subflow in flowHolder.GetFlows())
                     {
                         FindSteps(subflow, map);
                     }
                 }
             }
         }
     }
 }
コード例 #11
0
        public virtual void OnPreBuild(IStepLocator locator)
        {
            if (locator.Get <BuildPipelineStep>().BuildTarget != BuildTarget.Android)
            {
                return;
            }

            // Прописываем BundleVersionCode.
            if (BundleVersionCode >= 0)
            {
                PlayerSettings.Android.bundleVersionCode = BundleVersionCode;
            }

            EditorUserBuildSettings.androidETC2Fallback          = AndroidETC2Fallback;
            EditorUserBuildSettings.exportAsGoogleAndroidProject = ExportAsGoogleAndroidProject;
            EditorUserBuildSettings.androidCreateSymbolsZip      = AndroidCreateSymbolsZip;

            EditorUserBuildSettings.androidBuildSubtarget = AndroidBuildSubtarget;
            EditorUserBuildSettings.androidBuildSystem    = AndroidBuildSystem;
            EditorUserBuildSettings.buildAppBundle        = AndroidBuildAppBundle;

            PlayerSettings.Android.useCustomKeystore = UseCustomKeyStore;

            PlayerSettings.Android.useAPKExpansionFiles       = UseAPKExpansionFiles;
            PlayerSettings.Android.minSdkVersion              = AndroidMinSdkVersion;
            PlayerSettings.Android.targetSdkVersion           = AndroidTargetSdkVersion;
            PlayerSettings.Android.targetArchitectures        = AndroidTargetArchitecture;
            PlayerSettings.Android.buildApkPerCpuArchitecture = BuildApkPerCpuArchitecture;
            PlayerSettings.Android.preferredInstallLocation   = AndroidPreferredInstallLocation;
            PlayerSettings.Android.forceInternetPermission    = AndroidForceInternetPermission;
            PlayerSettings.Android.forceSDCardPermission      = AndroidForceSDCardPermission;

            if (!string.IsNullOrEmpty(GradlePath))
            {
                AndroidExternalToolsSettings.gradlePath = GradlePath;
            }

            if (!string.IsNullOrEmpty(JdkRootPath))
            {
                AndroidExternalToolsSettings.jdkRootPath = JdkRootPath;
            }

            if (!string.IsNullOrEmpty(NdkRootPath))
            {
                AndroidExternalToolsSettings.ndkRootPath = NdkRootPath;
            }

            if (!string.IsNullOrEmpty(SdkRootPath))
            {
                AndroidExternalToolsSettings.sdkRootPath = SdkRootPath;
            }

            AndroidExternalToolsSettings.maxJvmHeapSize = MaxJvmHeapSize;

            if (PlayerSettings.Android.useCustomKeystore)
            {
                PlayerSettings.Android.keystoreName = AndroidKeystore;
                if (!File.Exists(PlayerSettings.Android.keystoreName))
                {
                    throw new Exception("Keystore file '" + PlayerSettings.Android.keystoreName + "' is not exists!");
                }

                PlayerSettings.Android.keystorePass = AndroidKeystorePassword;
                if (string.IsNullOrEmpty(PlayerSettings.Android.keystorePass))
                {
                    throw new Exception("Keystore password not set!");
                }

                PlayerSettings.Android.keyaliasName = AndroidKeyalias;
                if (string.IsNullOrEmpty(PlayerSettings.Android.keyaliasName))
                {
                    throw new Exception("KeyAlias not set!");
                }

                PlayerSettings.Android.keyaliasPass = AndroidKeyaliasPassword;
                if (string.IsNullOrEmpty(PlayerSettings.Android.keyaliasPass))
                {
                    throw new Exception("KeyAlias password not set!");
                }
            }
        }
コード例 #12
0
 /// <summary>
 /// Удаляет файл на локальной машине
 /// </summary>
 public virtual void OnPostBuild(IStepLocator locator)
 {
     AssetDatabase.DeleteAsset(BuildInfoFullPath);
     AssetDatabase.Refresh(ImportAssetOptions.Default);
 }
コード例 #13
0
        public virtual void OnPreBuild(IStepLocator locator)
        {
            // Опции билдера
            var opts = BuildOptions.None;

            if (Development)
            {
                opts |= BuildOptions.Development;
            }

            if (AllowDebugging)
            {
                opts |= BuildOptions.AllowDebugging | BuildOptions.ConnectWithProfiler;

                if (BuildWithDeepProfilingSupport)
                {
                    opts |= BuildOptions.EnableDeepProfilingSupport;
                }

                if (ScriptsOnlyBuild)
                {
                    opts |= BuildOptions.BuildScriptsOnly;
                }
            }

            if (ShowBuiltPlayer)
            {
                opts |= BuildOptions.ShowBuiltPlayer;
            }

            if (ForceAppendToExistProject)
            {
                opts |= BuildOptions.AcceptExternalModificationsToPlayer;
            }

            if (UseLZ4Compression)
            {
                opts |= BuildOptions.CompressWithLz4;
            }

            if (ServerBuild)
            {
                opts |= BuildOptions.EnableHeadlessMode;
            }

#if UNITY_2021
            EditorUserBuildSettings.il2CppCodeGeneration = Il2CppCodeGeneration;
            PlayerSettings.WebGL.debugSymbolMode         = WebGLDebugSymbolMode;
#endif

#if UNITY_2020_2_OR_NEWER
            SerializedObject projectSettingsManager = new SerializedObject(AssetDatabase.LoadAllAssetsAtPath("ProjectSettings/ProjectSettings.asset")[0]);
            projectSettingsManager.FindProperty("overrideDefaultApplicationIdentifier").boolValue = true;
            projectSettingsManager.ApplyModifiedProperties();
#endif
            EditorUserBuildSettings.waitForManagedDebugger = WaitForManagedDebugger;

#if UNITY_2021_3_OR_NEWER
            EditorUserBuildSettings.standaloneBuildSubtarget = BuildSubTarget;
#endif
            //Scripting options
            var currentBuildTarget = BuildPipeline.GetBuildTargetGroup(BuildTarget);

            PlayerSettings.SetScriptingBackend(currentBuildTarget, ScriptingBackend);
            PlayerSettings.SetApiCompatibilityLevel(currentBuildTarget, ApiCompatibilityLevel);
            PlayerSettings.SetIl2CppCompilerConfiguration(currentBuildTarget, Il2CppCompilerConfiguration);

            PlayerSettings.SetManagedStrippingLevel(currentBuildTarget, CodeStrippingLevel);
            PlayerSettings.stripEngineCode = StripEngineCode;

            // Прописываем bundleId
            PlayerSettings.SetApplicationIdentifier(currentBuildTarget, BundleIdentifier);

            PlayerSettings.gcIncremental             = UseIncrementalGC;
            PlayerSettings.allowUnsafeCode           = AllowUnsafeCode;
            PlayerSettings.bakeCollisionMeshes       = BakeCollisionMeshes;
            PlayerSettings.stripUnusedMeshComponents = StripUnusedMeshComponents;

            PlayerSettings.SetStackTraceLogType(LogType.Assert, AssertStackTraceLogType);
            PlayerSettings.SetStackTraceLogType(LogType.Error, ErrorStackTraceLogType);
            PlayerSettings.SetStackTraceLogType(LogType.Exception, ExceptionStackTraceLogType);
            PlayerSettings.SetStackTraceLogType(LogType.Log, LogStackTraceLogType);
            PlayerSettings.SetStackTraceLogType(LogType.Warning, WarningStackTraceLogType);

            if (string.IsNullOrEmpty(BuildDir))
            {
                BuildDir = EditorUserBuildSettings.GetBuildLocation(BuildTarget);
            }

            // запоминаем директорию сборки
            EditorUserBuildSettings.SetBuildLocation(BuildTarget, BuildDir);

            // Собственно, сборка
            Debug.Log("Full build path: '" + BuildFullPath + "'");
            Directory.CreateDirectory(BuildFullDir);

            if (!DryRun)
            {
#if UNITY_2021_3_OR_NEWER
                BuildPlayerOptions buildPlayerOptions = new BuildPlayerOptions
                {
                    scenes           = Scenes.ToArray(),
                    locationPathName = BuildFullPath,
                    target           = BuildTarget,
                    subtarget        = ( int )BuildSubTarget,
                    options          = opts,
                };

                var report  = BuildPipeline.BuildPlayer(buildPlayerOptions);
                var summary = report.summary;

                if (summary.result != UnityEditor.Build.Reporting.BuildResult.Succeeded)
                {
                    throw new Exception($"Build failed with {report.summary.totalErrors} errors and {report.summary.totalWarnings} warnings");
                }
#else
                var report = BuildPipeline.BuildPlayer(Scenes.ToArray(), BuildFullPath, BuildTarget, opts);

                if (report.summary.result != UnityEditor.Build.Reporting.BuildResult.Succeeded)
                {
                    throw new Exception($"Build failed with {report.summary.totalErrors} errors and {report.summary.totalWarnings} warnings");
                }
#endif
            }
            else
            {
                var scenes  = string.Join(", ", Scenes);
                var optsStr = opts.ToString();
                Debug.Log($"Dry Run selected. Will build player with:\nScenes: {scenes}\nBuildOptions: {optsStr}");
            }
        }
コード例 #14
0
        public virtual void OnPreBuild(IStepLocator locator)
        {
            // Опции билдера
            var opts = BuildOptions.None;

            if (Development)
            {
                opts |= BuildOptions.Development;
            }

            if (AllowDebugging)
            {
                opts |= BuildOptions.AllowDebugging | BuildOptions.ConnectWithProfiler;
            }

            if (ShowBuiltPlayer)
            {
                opts |= BuildOptions.ShowBuiltPlayer;
            }

            if (ForceAppendToExistProject)
            {
                opts |= BuildOptions.AcceptExternalModificationsToPlayer;
            }

            if (UseLZ4Compression)
            {
                opts |= BuildOptions.CompressWithLz4;
            }

#if UNITY_2020_2_OR_NEWER
            SerializedObject projectSettingsManager = new SerializedObject(AssetDatabase.LoadAllAssetsAtPath("ProjectSettings/ProjectSettings.asset")[0]);
            projectSettingsManager.FindProperty("overrideDefaultApplicationIdentifier").boolValue = true;
            projectSettingsManager.ApplyModifiedProperties();
#endif

            // Прописываем bundleId
            PlayerSettings.SetApplicationIdentifier(BuildPipeline.GetBuildTargetGroup(BuildTarget), BundleIdentifier);

            if (string.IsNullOrEmpty(BuildDir))
            {
                BuildDir = EditorUserBuildSettings.GetBuildLocation(BuildTarget);
            }

            // запоминаем директорию сборки
            EditorUserBuildSettings.SetBuildLocation(BuildTarget, BuildDir);

            // Собственно, сборка
            Debug.Log("Full build path: '" + BuildFullPath + "'");
            Directory.CreateDirectory(BuildFullDir);

            if (!DryRun)
            {
                var report = BuildPipeline.BuildPlayer(Scenes.ToArray(), BuildFullPath, BuildTarget, opts);

                if (report.summary.result != UnityEditor.Build.Reporting.BuildResult.Succeeded)
                {
                    throw new Exception($"Build failed with {report.summary.totalErrors} errors and {report.summary.totalWarnings} warnings");
                }
            }
            else
            {
                var scenes  = string.Join(", ", Scenes);
                var optsStr = opts.ToString();
                Debug.Log($"Dry Run selected. Will build player with:\nScenes: {scenes}\nBuildOptions: {optsStr}");
            }
        }