Update editor logic

pull/40/head
hevinci 2022-09-28 11:46:23 +08:00
parent fe47de01d3
commit c8d3f6efed
11 changed files with 1 additions and 179 deletions

View File

@ -59,7 +59,6 @@ namespace YooAsset.Editor
new TaskCreatePatchManifest(), //创建清单文件
new TaskCreateReport(), //创建报告文件
new TaskCreatePatchPackage(), //制作补丁包
new TaskCopyBuildinFiles(), //拷贝内置文件
};
}
else if (buildParameters.BuildPipeline == EBuildPipeline.ScriptableBuildPipeline)
@ -74,7 +73,6 @@ namespace YooAsset.Editor
new TaskCreatePatchManifest(), //创建清单文件
new TaskCreateReport(), //创建报告文件
new TaskCreatePatchPackage(), //制作补丁包
new TaskCopyBuildinFiles(), //拷贝内置文件
};
}
else

View File

@ -20,11 +20,6 @@ namespace YooAsset.Editor
/// </summary>
public string BuildPackage = string.Empty;
/// <summary>
/// 内置资源标签(首包资源标签)
/// </summary>
public string BuildTags = string.Empty;
/// <summary>
/// 压缩方式
/// </summary>

View File

@ -27,7 +27,6 @@ namespace YooAsset.Editor
private TextField _buildOutputField;
private EnumField _buildPipelineField;
private EnumField _buildModeField;
private TextField _buildinTagsField;
private PopupField<string> _buildPackageField;
private PopupField<string> _encryptionField;
private EnumField _compressionField;
@ -90,15 +89,6 @@ namespace YooAsset.Editor
RefreshWindow();
});
// 内置资源标签
_buildinTagsField = root.Q<TextField>("BuildinTags");
_buildinTagsField.SetValueWithoutNotify(AssetBundleBuilderSettingData.Setting.BuildTags);
_buildinTagsField.RegisterValueChangedCallback(evt =>
{
AssetBundleBuilderSettingData.IsDirty = true;
AssetBundleBuilderSettingData.Setting.BuildTags = _buildinTagsField.value;
});
// 构建包裹
var buildPackageContainer = root.Q("BuildPackageContainer");
if (_buildPackageNames.Count > 0)
@ -204,7 +194,6 @@ namespace YooAsset.Editor
{
var buildMode = AssetBundleBuilderSettingData.Setting.BuildMode;
bool enableElement = buildMode == EBuildMode.ForceRebuild;
_buildinTagsField.SetEnabled(enableElement);
_encryptionField.SetEnabled(enableElement);
_compressionField.SetEnabled(enableElement);
_outputNameStyleField.SetEnabled(enableElement);
@ -239,10 +228,8 @@ namespace YooAsset.Editor
buildParameters.BuildPipeline = AssetBundleBuilderSettingData.Setting.BuildPipeline;
buildParameters.BuildMode = AssetBundleBuilderSettingData.Setting.BuildMode;
buildParameters.BuildPackage = AssetBundleBuilderSettingData.Setting.BuildPackage;
buildParameters.BuildinTags = AssetBundleBuilderSettingData.Setting.BuildTags;
buildParameters.VerifyBuildingResult = true;
buildParameters.EnableAddressable = AssetBundleCollectorSettingData.Setting.EnableAddressable;
buildParameters.CopyBuildinTagFiles = AssetBundleBuilderSettingData.Setting.BuildMode == EBuildMode.ForceRebuild;
buildParameters.EncryptionServices = CreateEncryptionServicesInstance();
buildParameters.CompressOption = AssetBundleBuilderSettingData.Setting.CompressOption;
buildParameters.OutputNameStyle = AssetBundleBuilderSettingData.Setting.OutputNameStyle;

View File

@ -10,7 +10,6 @@
<ui:VisualElement name="EncryptionContainer" style="height: 24px;" />
<uie:EnumField label="Compression" value="Center" name="Compression" />
<uie:EnumField label="Output Name Style" value="Center" name="OutputNameStyle" />
<ui:TextField picking-mode="Ignore" label="Buildin Tags" name="BuildinTags" />
<ui:Button text="构建" display-tooltip-when-elided="true" name="Build" style="height: 50px; background-color: rgb(40, 106, 42); margin-top: 10px;" />
</ui:VisualElement>
</ui:UXML>

View File

@ -61,12 +61,6 @@ namespace YooAsset.Editor
/// </summary>
public string BuildPackage;
/// <summary>
/// 内置资源标签集合(首包资源标签)
/// 注意:分号为分隔符
/// </summary>
public string BuildinTags;
/// <summary>
/// 验证构建结果
@ -77,12 +71,6 @@ namespace YooAsset.Editor
/// 启用可寻址资源定位
/// </summary>
public bool EnableAddressable = false;
/// <summary>
/// 拷贝内置资源文件到StreamingAssets目录首包资源文件
/// </summary>
public bool CopyBuildinTagFiles = false;
/// <summary>
/// 加密类
@ -108,14 +96,5 @@ namespace YooAsset.Editor
/// 忽略类型树变化
/// </summary>
public bool IgnoreTypeTreeChanges = true;
/// <summary>
/// 获取内置资源标签列表(首包资源标签)
/// </summary>
public List<string> GetBuildinTags()
{
return StringUtility.StringToStringList(BuildinTags, ';');
}
}
}

View File

@ -48,21 +48,11 @@ namespace YooAsset.Editor
/// </summary>
public string BuildPackage;
/// <summary>
/// 内置资源标签
/// </summary>
public string BuildinTags;
/// <summary>
/// 启用可寻址资源定位
/// </summary>
public bool EnableAddressable;
/// <summary>
/// 拷贝内置资源文件
/// </summary>
public bool CopyBuildinTagFiles;
/// <summary>
/// 加密服务类名称
/// </summary>
@ -79,8 +69,6 @@ namespace YooAsset.Editor
public int MainAssetTotalCount;
public int AllBundleTotalCount;
public long AllBundleTotalSize;
public int BuildinBundleTotalCount;
public long BuildinBundleTotalSize;
public int EncryptedBundleTotalCount;
public long EncryptedBundleTotalSize;
public int RawBundleTotalCount;

View File

@ -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}");
}
}
}

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 5c77e17c3a3a57548a218f1cd26f5a55
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -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;

View File

@ -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;

View File

@ -67,10 +67,8 @@ namespace YooAsset.Editor
_items.Add(new ItemWrapper("构建管线", $"{buildReport.Summary.BuildPipeline}"));
_items.Add(new ItemWrapper("构建模式", $"{buildReport.Summary.BuildMode}"));
_items.Add(new ItemWrapper("构建包裹", $"{buildReport.Summary.BuildPackage}"));
_items.Add(new ItemWrapper("内置资源标签", $"{buildReport.Summary.BuildinTags}"));
_items.Add(new ItemWrapper("启用可寻址资源定位", $"{buildReport.Summary.EnableAddressable}"));
_items.Add(new ItemWrapper("拷贝内置资源文件", $"{buildReport.Summary.CopyBuildinTagFiles}"));
_items.Add(new ItemWrapper("加密服务类名称", $"{buildReport.Summary.EncryptionServicesClassName}"));
_items.Add(new ItemWrapper(string.Empty, string.Empty));
@ -86,8 +84,6 @@ namespace YooAsset.Editor
_items.Add(new ItemWrapper("主资源总数", $"{buildReport.Summary.MainAssetTotalCount}"));
_items.Add(new ItemWrapper("资源包总数", $"{buildReport.Summary.AllBundleTotalCount}"));
_items.Add(new ItemWrapper("资源包总大小", ConvertSize(buildReport.Summary.AllBundleTotalSize)));
_items.Add(new ItemWrapper("内置资源包总数", $"{buildReport.Summary.BuildinBundleTotalCount}"));
_items.Add(new ItemWrapper("内置资源包总大小", ConvertSize(buildReport.Summary.BuildinBundleTotalSize)));
_items.Add(new ItemWrapper("加密资源包总数", $"{buildReport.Summary.EncryptedBundleTotalCount}"));
_items.Add(new ItemWrapper("加密资源包总大小", ConvertSize(buildReport.Summary.EncryptedBundleTotalSize)));
_items.Add(new ItemWrapper("原生资源包总数", $"{buildReport.Summary.RawBundleTotalCount}"));