Update editor logic

This commit is contained in:
hevinci
2022-09-28 11:46:23 +08:00
parent fe47de01d3
commit c8d3f6efed
11 changed files with 1 additions and 179 deletions
@@ -1,67 +0,0 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
namespace YooAsset.Editor
{
[TaskAttribute("拷贝内置文件到流目录")]
public class TaskCopyBuildinFiles : IBuildTask
{
void IBuildTask.Run(BuildContext context)
{
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
if (buildParametersContext.Parameters.CopyBuildinTagFiles)
{
// 清空流目录
AssetBundleBuilderHelper.ClearStreamingAssetsFolder();
// 拷贝内置文件
CopyBuildinFilesToStreaming(buildParametersContext);
}
}
private void CopyBuildinFilesToStreaming(BuildParametersContext buildParametersContext)
{
string streamingAssetsOutputDirectory = AssetBundleBuilderHelper.GetStreamingAssetsFolderPath();
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
string packageName = buildParametersContext.Parameters.BuildPackage;
string packageCRC = buildParametersContext.OutputPackageCRC;
// 加载补丁清单
PatchManifest patchManifest = AssetBundleBuilderHelper.LoadPatchManifestFile(pipelineOutputDirectory, packageName, packageCRC);
// 拷贝文件列表
foreach (var patchBundle in patchManifest.BundleList)
{
if (patchBundle.IsBuildin == false)
continue;
string sourcePath = $"{pipelineOutputDirectory}/{patchBundle.BundleName}";
string destPath = $"{streamingAssetsOutputDirectory}/{patchBundle.FileName}";
EditorTools.CopyFile(sourcePath, destPath, true);
}
// 拷贝清单文件
{
string manifestFileName = YooAssetSettingsData.GetPatchManifestFileName(packageName, packageCRC);
string sourcePath = $"{pipelineOutputDirectory}/{manifestFileName}";
string destPath = $"{streamingAssetsOutputDirectory}/{manifestFileName}";
EditorTools.CopyFile(sourcePath, destPath, true);
}
// 拷贝静态版本文件
{
string versionFileName = YooAssetSettingsData.GetStaticVersionFileName(packageName);
string sourcePath = $"{pipelineOutputDirectory}/{versionFileName}";
string destPath = $"{streamingAssetsOutputDirectory}/{versionFileName}";
EditorTools.CopyFile(sourcePath, destPath, true);
}
// 刷新目录
AssetDatabase.Refresh();
BuildRunner.Log($"内置文件拷贝完成:{streamingAssetsOutputDirectory}");
}
}
}
@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 5c77e17c3a3a57548a218f1cd26f5a55
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -31,7 +31,6 @@ namespace YooAsset.Editor
patchManifest.EnableAddressable = buildParameters.EnableAddressable;
patchManifest.OutputNameStyle = (int)buildParameters.OutputNameStyle;
patchManifest.PackageName = buildParameters.BuildPackage;
patchManifest.BuildinTags = buildParameters.BuildinTags;
patchManifest.BundleList = GetAllPatchBundle(context);
patchManifest.AssetList = GetAllPatchAsset(context, patchManifest);
@@ -76,8 +75,6 @@ namespace YooAsset.Editor
var encryptionContext = context.GetContextObject<TaskEncryption.EncryptionContext>();
List<PatchBundle> result = new List<PatchBundle>(1000);
List<string> buildinTags = buildParameters.Parameters.GetBuildinTags();
foreach (var bundleInfo in buildMapContext.BundleInfos)
{
var bundleName = bundleInfo.BundleName;
@@ -86,29 +83,14 @@ namespace YooAsset.Editor
long fileSize = GetBundleFileSize(bundleInfo, buildParameters);
string[] tags = buildMapContext.GetBundleTags(bundleName);
bool isEncrypted = encryptionContext.IsEncryptFile(bundleName);
bool isBuildin = IsBuildinBundle(tags, buildinTags);
bool isRawFile = bundleInfo.IsRawFile;
PatchBundle patchBundle = new PatchBundle(bundleName, fileHash, fileCRC, fileSize, tags);
patchBundle.SetFlagsValue(isEncrypted, isBuildin, isRawFile);
patchBundle.SetFlagsValue(isRawFile, isEncrypted);
result.Add(patchBundle);
}
return result;
}
private bool IsBuildinBundle(string[] bundleTags, List<string> buildinTags)
{
// 注意:没有任何分类标签的Bundle文件默认为内置文件
if (bundleTags.Length == 0)
return true;
foreach (var tag in bundleTags)
{
if (buildinTags.Contains(tag))
return true;
}
return false;
}
private string GetBundleFileHash(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
{
var buildMode = buildParametersContext.Parameters.BuildMode;
@@ -46,9 +46,7 @@ namespace YooAsset.Editor
buildReport.Summary.BuildPipeline = buildParameters.BuildPipeline;
buildReport.Summary.BuildMode = buildParameters.BuildMode;
buildReport.Summary.BuildPackage = buildParameters.BuildPackage;
buildReport.Summary.BuildinTags = buildParameters.BuildinTags;
buildReport.Summary.EnableAddressable = buildParameters.EnableAddressable;
buildReport.Summary.CopyBuildinTagFiles = buildParameters.CopyBuildinTagFiles;
buildReport.Summary.EncryptionServicesClassName = buildParameters.EncryptionServices == null ?
"null" : buildParameters.EncryptionServices.GetType().FullName;
@@ -63,8 +61,6 @@ namespace YooAsset.Editor
buildReport.Summary.MainAssetTotalCount = GetMainAssetCount(patchManifest);
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);
@@ -178,26 +174,6 @@ namespace YooAsset.Editor
}
return fileBytes;
}
private int GetBuildinBundleCount(PatchManifest patchManifest)
{
int fileCount = 0;
foreach (var patchBundle in patchManifest.BundleList)
{
if (patchBundle.IsBuildin)
fileCount++;
}
return fileCount;
}
private long GetBuildinBundleSize(PatchManifest patchManifest)
{
long fileBytes = 0;
foreach (var patchBundle in patchManifest.BundleList)
{
if (patchBundle.IsBuildin)
fileBytes += patchBundle.FileSize;
}
return fileBytes;
}
private int GetEncryptedBundleCount(PatchManifest patchManifest)
{
int fileCount = 0;