void IBuildTask.Run(BuildContext context)
        {
            var buildParametersContext = context.GetContextObject <AssetBundleBuilder.BuildParametersContext>();
            var buildMapContext        = context.GetContextObject <BuildMapContext>();

            // 模拟构建模式下跳过引擎构建
            var buildMode = buildParametersContext.Parameters.BuildMode;

            if (buildMode == EBuildMode.SimulateBuild)
            {
                return;
            }

            BuildAssetBundleOptions opt           = buildParametersContext.GetPipelineBuildOptions();
            AssetBundleManifest     unityManifest = BuildPipeline.BuildAssetBundles(buildParametersContext.PipelineOutputDirectory, buildMapContext.GetPipelineBuilds(), opt, buildParametersContext.Parameters.BuildTarget);

            if (unityManifest == null)
            {
                throw new Exception("构建过程中发生错误!");
            }

            BuildRunner.Log("Unity引擎打包成功!");
            UnityManifestContext unityManifestContext = new UnityManifestContext();

            unityManifestContext.UnityManifest = unityManifest;
            context.SetContextObject(unityManifestContext);

            // 拷贝原生文件
            if (buildMode == EBuildMode.ForceRebuild || buildMode == EBuildMode.IncrementalBuild)
            {
                CopyRawBundle(buildMapContext, buildParametersContext);
            }
        }
Exemple #2
0
        void IBuildTask.Run(BuildContext context)
        {
            var buildParameters = context.GetContextObject <AssetBundleBuilder.BuildParametersContext>();
            var buildMap        = context.GetContextObject <TaskGetBuildMap.BuildMapContext>();

            BuildLogger.Log($"开始构建......");
            BuildAssetBundleOptions opt      = buildParameters.GetPiplineBuildOptions();
            AssetBundleManifest     manifest = BuildPipeline.BuildAssetBundles(buildParameters.PipelineOutputDirectory, buildMap.GetPipelineBuilds(), opt, buildParameters.Parameters.BuildTarget);

            if (manifest == null)
            {
                throw new Exception("构建过程中发生错误!");
            }

            UnityManifestContext unityManifestContext = new UnityManifestContext();

            unityManifestContext.Manifest = manifest;
            context.SetContextObject(unityManifestContext);
        }