private void AssetListView_onSelectionChange(IEnumerable <object> objs)
 {
     foreach (var item in objs)
     {
         ReportAssetInfo assetInfo = item as ReportAssetInfo;
         FillDependListView(assetInfo);
     }
 }
        private void BindIncludeListViewItem(VisualElement element, int index)
        {
            List <ReportAssetInfo> containsList = _includeListView.itemsSource as List <ReportAssetInfo>;
            ReportAssetInfo        assetInfo    = containsList[index];

            // Asset Path
            var label1 = element.Q <Label>("Label1");

            label1.text = assetInfo.AssetPath;

            // GUID
            var label2 = element.Q <Label>("Label2");

            label2.text = assetInfo.AssetGUID;
        }
        // 依赖列表相关
        private void FillDependListView(ReportAssetInfo assetInfo)
        {
            List <ReportBundleInfo> bundles = new List <ReportBundleInfo>();
            var mainBundle = _buildReport.GetBundleInfo(assetInfo.MainBundleName);

            bundles.Add(mainBundle);
            foreach (string dependBundleName in assetInfo.DependBundles)
            {
                var dependBundle = _buildReport.GetBundleInfo(dependBundleName);
                bundles.Add(dependBundle);
            }

            _dependListView.Clear();
            _dependListView.ClearSelection();
            _dependListView.itemsSource = bundles;
            _dependListView.Rebuild();
            _bottomBar1.text = $"Depend Bundles ({bundles.Count})";
        }
예제 #4
0
        private void CreateReportFile(AssetBundleBuilder.BuildParametersContext buildParameters, BuildMapContext buildMapContext)
        {
            PatchManifest patchManifest = AssetBundleBuilderHelper.LoadPatchManifestFile(buildParameters.PipelineOutputDirectory, buildParameters.Parameters.BuildVersion);
            BuildReport   buildReport   = new BuildReport();

            // 概述信息
            {
                buildReport.Summary.UnityVersion                = UnityEngine.Application.unityVersion;
                buildReport.Summary.BuildTime                   = DateTime.Now.ToString();
                buildReport.Summary.BuildSeconds                = (int)buildParameters.GetBuildingSeconds();
                buildReport.Summary.BuildTarget                 = buildParameters.Parameters.BuildTarget;
                buildReport.Summary.BuildMode                   = buildParameters.Parameters.BuildMode;
                buildReport.Summary.BuildVersion                = buildParameters.Parameters.BuildVersion;
                buildReport.Summary.BuildinTags                 = buildParameters.Parameters.BuildinTags;
                buildReport.Summary.EnableAddressable           = buildParameters.Parameters.EnableAddressable;
                buildReport.Summary.AppendFileExtension         = buildParameters.Parameters.AppendFileExtension;
                buildReport.Summary.CopyBuildinTagFiles         = buildParameters.Parameters.CopyBuildinTagFiles;
                buildReport.Summary.AutoCollectShaders          = AssetBundleCollectorSettingData.Setting.AutoCollectShaders;
                buildReport.Summary.ShadersBundleName           = AssetBundleCollectorSettingData.Setting.ShadersBundleName;
                buildReport.Summary.EncryptionServicesClassName = buildParameters.Parameters.EncryptionServices == null ?
                                                                  "null" : buildParameters.Parameters.EncryptionServices.GetType().FullName;

                // 构建参数
                buildReport.Summary.CompressOption        = buildParameters.Parameters.CompressOption;
                buildReport.Summary.DisableWriteTypeTree  = buildParameters.Parameters.DisableWriteTypeTree;
                buildReport.Summary.IgnoreTypeTreeChanges = buildParameters.Parameters.IgnoreTypeTreeChanges;

                // 构建结果
                buildReport.Summary.AssetFileTotalCount       = buildMapContext.AssetFileCount;
                buildReport.Summary.AllBundleTotalCount       = GetAllBundleCount(patchManifest);
                buildReport.Summary.AllBundleTotalSize        = GetAllBundleSize(patchManifest);
                buildReport.Summary.BuildinBundleTotalCount   = GetBuildinBundleCount(patchManifest);
                buildReport.Summary.BuildinBundleTotalSize    = GetBuildinBundleSize(patchManifest);
                buildReport.Summary.EncryptedBundleTotalCount = GetEncryptedBundleCount(patchManifest);
                buildReport.Summary.EncryptedBundleTotalSize  = GetEncryptedBundleSize(patchManifest);
                buildReport.Summary.RawBundleTotalCount       = GetRawBundleCount(patchManifest);
                buildReport.Summary.RawBundleTotalSize        = GetRawBundleSize(patchManifest);
            }

            // 资源对象列表
            buildReport.AssetInfos = new List <ReportAssetInfo>(patchManifest.AssetList.Count);
            foreach (var patchAsset in patchManifest.AssetList)
            {
                var             mainBundle      = patchManifest.BundleList[patchAsset.BundleID];
                ReportAssetInfo reportAssetInfo = new ReportAssetInfo();
                reportAssetInfo.Address        = patchAsset.Address;
                reportAssetInfo.AssetPath      = patchAsset.AssetPath;
                reportAssetInfo.AssetTags      = patchAsset.AssetTags;
                reportAssetInfo.AssetGUID      = AssetDatabase.AssetPathToGUID(patchAsset.AssetPath);
                reportAssetInfo.MainBundleName = mainBundle.BundleName;
                reportAssetInfo.MainBundleSize = mainBundle.SizeBytes;
                reportAssetInfo.DependBundles  = GetDependBundles(patchManifest, patchAsset);
                reportAssetInfo.DependAssets   = GetDependAssets(buildMapContext, mainBundle.BundleName, patchAsset.AssetPath);
                buildReport.AssetInfos.Add(reportAssetInfo);
            }

            // 资源包列表
            buildReport.BundleInfos = new List <ReportBundleInfo>(patchManifest.BundleList.Count);
            foreach (var patchBundle in patchManifest.BundleList)
            {
                ReportBundleInfo reportBundleInfo = new ReportBundleInfo();
                reportBundleInfo.BundleName = patchBundle.BundleName;
                reportBundleInfo.Hash       = patchBundle.Hash;
                reportBundleInfo.CRC        = patchBundle.CRC;
                reportBundleInfo.SizeBytes  = patchBundle.SizeBytes;
                reportBundleInfo.Tags       = patchBundle.Tags;
                reportBundleInfo.Flags      = patchBundle.Flags;
                buildReport.BundleInfos.Add(reportBundleInfo);
            }

            // 删除旧文件
            string filePath = $"{buildParameters.PipelineOutputDirectory}/{YooAssetSettingsData.GetReportFileName(buildParameters.Parameters.BuildVersion)}";

            if (File.Exists(filePath))
            {
                File.Delete(filePath);
            }

            // 序列化文件
            BuildReport.Serialize(filePath, buildReport);
            BuildRunner.Log($"资源构建报告文件创建完成:{filePath}");
        }