public override BuildState OnUpdate()
        {
            BuildHelper.AddBuildNum();
            var buildNumber = BuildHelper.GetBuildNum();

            Debug.Log("当前Build版本:" + buildNumber);

            return(BuildState.Success);
        }
Пример #2
0
        public override BuildState OnUpdate()
        {
            var listScene = BuildHelper.GetAllScenesInBuild();

            var fileName = ExeName;

            if (ExeName.EndsWith(".exe") == false)
            {
                fileName += ".exe";
            }

            var x = X64 ? "x64" : "x86";

            var dirName = string.Format("{0}_{3}_build{1}_{2:yyyyMMddHHmm}", this.ProjectName, BuildHelper.GetBuildNum(), DateTime.Now, x);

            BuildHelper.AddBuildNum();

            var path = Path.Combine(BuildPath, dirName);

            path = Path.Combine(path, fileName);

            var buildTarget = X64 ? BuildTarget.StandaloneWindows64 : BuildTarget.StandaloneWindows;

            BuildPlayerOptions buildPlayerOptions = new BuildPlayerOptions();

            buildPlayerOptions.scenes           = listScene.ToArray();
            buildPlayerOptions.locationPathName = path;
            buildPlayerOptions.target           = buildTarget;
            buildPlayerOptions.options          = BuildOptions.None;
            BuildReport  report  = BuildPipeline.BuildPlayer(buildPlayerOptions);
            BuildSummary summary = report.summary;

            if (summary.result == BuildResult.Succeeded)
            {
                Context.Set("BuildPath", path);
                Debug.Log("Build succeeded: " + summary.totalSize + " bytes");
                return(BuildState.Success);
            }
            else if (summary.result == BuildResult.Failed)
            {
                Debug.LogError("Build failed");
                throw new Exception("Build Fail");
            }
            return(BuildState.Failure);
        }
Пример #3
0
        public override BuildState OnUpdate()
        {
            PlayerSettings.keyaliasPass = KeyAliasPass;
            PlayerSettings.keystorePass = KeyStorePass;

            var listScene = BuildHelper.GetAllScenesInBuild();

            // projectName_yyyyMMddHHmm
            var apkName = string.Format("{0}_build{1}_{2:yyyyMMddHHmm}.apk",
                                        ProjectName,
                                        BuildHelper.GetBuildNum(),
                                        DateTime.Now);

            BuildHelper.AddBuildNum();

            var path = Path.Combine(BuildPath, apkName);

            var dir = Path.GetDirectoryName(path);

            if (dir != null && !Directory.Exists(dir))
            {
                Directory.CreateDirectory(dir);
            }

            EditorPrefs.SetString("BuildMechine.ProjectPath", path);

            var res = BuildPipeline.BuildPlayer(listScene.ToArray(), path, BuildTarget.Android, BuildOptions.None);

            if (string.IsNullOrEmpty(res.ToString()) == false)
            {
                throw new Exception("Build Fail : " + res);
            }

            Debug.LogFormat("打包至 {0} 结果 {1}", path, res);

            Context.Set("BuildPath", path);

            return(BuildState.Success);
        }
        public override BuildState OnUpdate()
        {
            var listScene = BuildHelper.GetAllScenesInBuild();

            var fileName = ExeName;

            if (ExeName.EndsWith(".exe") == false)
            {
                fileName += ".exe";
            }

            var x = X64 ? "x64" : "x86";

            var dirName = string.Format("{0}_{3}_build{1}_{2:yyyyMMddHHmm}", this.ProjectName, BuildHelper.GetBuildNum(), DateTime.Now, x);

            BuildHelper.AddBuildNum();

            var path = Path.Combine(BuildPath, dirName);

            path = Path.Combine(path, fileName);

            var buildTarget = X64 ? BuildTarget.StandaloneWindows64 : BuildTarget.StandaloneWindows;

            var res = BuildPipeline.BuildPlayer(listScene.ToArray(), path, buildTarget, BuildOptions.None);

            if (string.IsNullOrEmpty(res) == false)
            {
                throw new Exception("Build Fail : " + res);
            }

            Debug.LogFormat("打包至 {0} 结果 {1}", path, res);

            Context.Set("BuildPath", path);

            return(BuildState.Success);
        }