mirror of
https://github.com/tuyoogame/YooAsset.git
synced 2026-05-23 01:00:16 +00:00
Compare commits
20 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e340af90ed | ||
|
|
7fa7cc4af1 | ||
|
|
ca3c011f34 | ||
|
|
669339d5b4 | ||
|
|
c6567650fe | ||
|
|
3ae70412fa | ||
|
|
d575850f9f | ||
|
|
d1439da54e | ||
|
|
89022d3df4 | ||
|
|
3c38fe6155 | ||
|
|
e68ece6925 | ||
|
|
ea9b8874cc | ||
|
|
475efd90fc | ||
|
|
682605d5c2 | ||
|
|
256844ddf5 | ||
|
|
96f95bbd99 | ||
|
|
4f7bb945e0 | ||
|
|
0d69d779f6 | ||
|
|
5df26908fb | ||
|
|
fb5e289de0 |
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
[仓库链接](https://github.com/Cysharp/UniTask)
|
[仓库链接](https://github.com/Cysharp/UniTask)
|
||||||
- 请去下载对应的源码,并删除此目录最后的波浪线
|
- 请去下载对应的源码,并删除此目录最后的波浪线
|
||||||
|
- 在项目的 `asmdef` 文件中添加对 `UniTask.YooAsset` 的引用
|
||||||
- 在 UniTask `_InternalVisibleTo.cs` 文件中增加 `[assembly: InternalsVisibleTo("UniTask.YooAsset")]` 后即可使用
|
- 在 UniTask `_InternalVisibleTo.cs` 文件中增加 `[assembly: InternalsVisibleTo("UniTask.YooAsset")]` 后即可使用
|
||||||
|
|
||||||
## 代码示例
|
## 代码示例
|
||||||
|
|||||||
@@ -2,6 +2,23 @@
|
|||||||
|
|
||||||
All notable changes to this package will be documented in this file.
|
All notable changes to this package will be documented in this file.
|
||||||
|
|
||||||
|
## [1.2.0] - 2022-07-18
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- 修复了ShaderVariantCollection刷新不及时问题。
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- 资源收集忽略了Gizmos资源文件。
|
||||||
|
- 解密服务接口增加解密文件信息参数。
|
||||||
|
- 资源收集窗体增加配置保存按钮。
|
||||||
|
- 资源构建窗体增加配置保存按钮。
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- 资源构建模块增加了可编程构建管线(SBP)的支持,开发者可以在内置构建管线和可编程构建管线之间自由选择,零修改成本。
|
||||||
|
|
||||||
## [1.1.1] - 2022-07-07
|
## [1.1.1] - 2022-07-07
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|||||||
@@ -18,29 +18,65 @@ namespace YooAsset.Editor
|
|||||||
// 清空旧数据
|
// 清空旧数据
|
||||||
_buildContext.ClearAllContext();
|
_buildContext.ClearAllContext();
|
||||||
|
|
||||||
|
// 检测构建参数是否为空
|
||||||
|
if (buildParameters == null)
|
||||||
|
{
|
||||||
|
throw new Exception($"{nameof(buildParameters)} is null !");
|
||||||
|
}
|
||||||
|
if (buildParameters.BuildPipeline == EBuildPipeline.ScriptableBuildPipeline)
|
||||||
|
{
|
||||||
|
if (buildParameters.SBPParameters == null)
|
||||||
|
throw new Exception($"{nameof(BuildParameters.SBPParameters)} is null !");
|
||||||
|
}
|
||||||
|
|
||||||
// 构建参数
|
// 构建参数
|
||||||
var buildParametersContext = new BuildParametersContext(buildParameters);
|
var buildParametersContext = new BuildParametersContext(buildParameters);
|
||||||
_buildContext.SetContextObject(buildParametersContext);
|
_buildContext.SetContextObject(buildParametersContext);
|
||||||
|
|
||||||
// 执行构建流程
|
// 是否显示LOG
|
||||||
List<IBuildTask> pipeline = new List<IBuildTask>
|
|
||||||
{
|
|
||||||
new TaskPrepare(), //前期准备工作
|
|
||||||
new TaskGetBuildMap(), //获取构建列表
|
|
||||||
new TaskBuilding(), //开始执行构建
|
|
||||||
new TaskVerifyBuildResult(), //验证构建结果
|
|
||||||
new TaskEncryption(), //加密资源文件
|
|
||||||
new TaskCreatePatchManifest(), //创建清单文件
|
|
||||||
new TaskCreateReport(), //创建报告文件
|
|
||||||
new TaskCreatePatchPackage(), //制作补丁包
|
|
||||||
new TaskCopyBuildinFiles(), //拷贝内置文件
|
|
||||||
};
|
|
||||||
|
|
||||||
if (buildParameters.BuildMode == EBuildMode.SimulateBuild)
|
if (buildParameters.BuildMode == EBuildMode.SimulateBuild)
|
||||||
BuildRunner.EnableLog = false;
|
BuildRunner.EnableLog = false;
|
||||||
else
|
else
|
||||||
BuildRunner.EnableLog = true;
|
BuildRunner.EnableLog = true;
|
||||||
|
|
||||||
|
// 创建构建节点
|
||||||
|
List<IBuildTask> pipeline;
|
||||||
|
if (buildParameters.BuildPipeline == EBuildPipeline.BuiltinBuildPipeline)
|
||||||
|
{
|
||||||
|
pipeline = new List<IBuildTask>
|
||||||
|
{
|
||||||
|
new TaskPrepare(), //前期准备工作
|
||||||
|
new TaskGetBuildMap(), //获取构建列表
|
||||||
|
new TaskBuilding(), //开始执行构建
|
||||||
|
new TaskVerifyBuildResult(), //验证构建结果
|
||||||
|
new TaskEncryption(), //加密资源文件
|
||||||
|
new TaskCreatePatchManifest(), //创建清单文件
|
||||||
|
new TaskCreateReport(), //创建报告文件
|
||||||
|
new TaskCreatePatchPackage(), //制作补丁包
|
||||||
|
new TaskCopyBuildinFiles(), //拷贝内置文件
|
||||||
|
};
|
||||||
|
}
|
||||||
|
else if (buildParameters.BuildPipeline == EBuildPipeline.ScriptableBuildPipeline)
|
||||||
|
{
|
||||||
|
pipeline = new List<IBuildTask>
|
||||||
|
{
|
||||||
|
new TaskPrepare(), //前期准备工作
|
||||||
|
new TaskGetBuildMap(), //获取构建列表
|
||||||
|
new TaskBuilding_SBP(), //开始执行构建
|
||||||
|
new TaskVerifyBuildResult_SBP(), //验证构建结果
|
||||||
|
new TaskEncryption(), //加密资源文件
|
||||||
|
new TaskCreatePatchManifest(), //创建清单文件
|
||||||
|
new TaskCreateReport(), //创建报告文件
|
||||||
|
new TaskCreatePatchPackage(), //制作补丁包
|
||||||
|
new TaskCopyBuildinFiles(), //拷贝内置文件
|
||||||
|
};
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 执行构建流程
|
||||||
bool succeed = BuildRunner.Run(pipeline, _buildContext);
|
bool succeed = BuildRunner.Run(pipeline, _buildContext);
|
||||||
if (succeed)
|
if (succeed)
|
||||||
Debug.Log($"{buildParameters.BuildMode} pipeline build succeed !");
|
Debug.Log($"{buildParameters.BuildMode} pipeline build succeed !");
|
||||||
|
|||||||
@@ -10,6 +10,11 @@ namespace YooAsset.Editor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public int BuildVersion = 0;
|
public int BuildVersion = 0;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 构建管线
|
||||||
|
/// </summary>
|
||||||
|
public EBuildPipeline BuildPipeline = EBuildPipeline.BuiltinBuildPipeline;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 构建模式
|
/// 构建模式
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -19,6 +19,11 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 配置数据是否被修改
|
||||||
|
/// </summary>
|
||||||
|
public static bool IsDirty { set; get; } = false;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 加载配置文件
|
/// 加载配置文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -34,6 +39,7 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
if (Setting != null)
|
if (Setting != null)
|
||||||
{
|
{
|
||||||
|
IsDirty = false;
|
||||||
EditorUtility.SetDirty(Setting);
|
EditorUtility.SetDirty(Setting);
|
||||||
AssetDatabase.SaveAssets();
|
AssetDatabase.SaveAssets();
|
||||||
Debug.Log($"{nameof(AssetBundleBuilderSetting)}.asset is saved!");
|
Debug.Log($"{nameof(AssetBundleBuilderSetting)}.asset is saved!");
|
||||||
|
|||||||
@@ -22,8 +22,10 @@ namespace YooAsset.Editor
|
|||||||
private List<Type> _encryptionServicesClassTypes;
|
private List<Type> _encryptionServicesClassTypes;
|
||||||
private List<string> _encryptionServicesClassNames;
|
private List<string> _encryptionServicesClassNames;
|
||||||
|
|
||||||
|
private Button _saveButton;
|
||||||
private TextField _buildOutputField;
|
private TextField _buildOutputField;
|
||||||
private IntegerField _buildVersionField;
|
private IntegerField _buildVersionField;
|
||||||
|
private EnumField _buildPipelineField;
|
||||||
private EnumField _buildModeField;
|
private EnumField _buildModeField;
|
||||||
private TextField _buildinTagsField;
|
private TextField _buildinTagsField;
|
||||||
private PopupField<string> _encryptionField;
|
private PopupField<string> _encryptionField;
|
||||||
@@ -43,7 +45,14 @@ namespace YooAsset.Editor
|
|||||||
|
|
||||||
visualAsset.CloneTree(root);
|
visualAsset.CloneTree(root);
|
||||||
|
|
||||||
|
// 配置保存按钮
|
||||||
|
_saveButton = root.Q<Button>("SaveButton");
|
||||||
|
_saveButton.clicked += SaveBtn_clicked;
|
||||||
|
|
||||||
|
// 构建平台
|
||||||
_buildTarget = EditorUserBuildSettings.activeBuildTarget;
|
_buildTarget = EditorUserBuildSettings.activeBuildTarget;
|
||||||
|
|
||||||
|
// 加密服务类
|
||||||
_encryptionServicesClassTypes = GetEncryptionServicesClassTypes();
|
_encryptionServicesClassTypes = GetEncryptionServicesClassTypes();
|
||||||
_encryptionServicesClassNames = _encryptionServicesClassTypes.Select(t => t.FullName).ToList();
|
_encryptionServicesClassNames = _encryptionServicesClassTypes.Select(t => t.FullName).ToList();
|
||||||
|
|
||||||
@@ -59,9 +68,22 @@ namespace YooAsset.Editor
|
|||||||
_buildVersionField.SetValueWithoutNotify(AssetBundleBuilderSettingData.Setting.BuildVersion);
|
_buildVersionField.SetValueWithoutNotify(AssetBundleBuilderSettingData.Setting.BuildVersion);
|
||||||
_buildVersionField.RegisterValueChangedCallback(evt =>
|
_buildVersionField.RegisterValueChangedCallback(evt =>
|
||||||
{
|
{
|
||||||
|
AssetBundleBuilderSettingData.IsDirty = true;
|
||||||
AssetBundleBuilderSettingData.Setting.BuildVersion = _buildVersionField.value;
|
AssetBundleBuilderSettingData.Setting.BuildVersion = _buildVersionField.value;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 构建管线
|
||||||
|
_buildPipelineField = root.Q<EnumField>("BuildPipeline");
|
||||||
|
_buildPipelineField.Init(AssetBundleBuilderSettingData.Setting.BuildPipeline);
|
||||||
|
_buildPipelineField.SetValueWithoutNotify(AssetBundleBuilderSettingData.Setting.BuildPipeline);
|
||||||
|
_buildPipelineField.style.width = 300;
|
||||||
|
_buildPipelineField.RegisterValueChangedCallback(evt =>
|
||||||
|
{
|
||||||
|
AssetBundleBuilderSettingData.IsDirty = true;
|
||||||
|
AssetBundleBuilderSettingData.Setting.BuildPipeline = (EBuildPipeline)_buildPipelineField.value;
|
||||||
|
RefreshWindow();
|
||||||
|
});
|
||||||
|
|
||||||
// 构建模式
|
// 构建模式
|
||||||
_buildModeField = root.Q<EnumField>("BuildMode");
|
_buildModeField = root.Q<EnumField>("BuildMode");
|
||||||
_buildModeField.Init(AssetBundleBuilderSettingData.Setting.BuildMode);
|
_buildModeField.Init(AssetBundleBuilderSettingData.Setting.BuildMode);
|
||||||
@@ -69,6 +91,7 @@ namespace YooAsset.Editor
|
|||||||
_buildModeField.style.width = 300;
|
_buildModeField.style.width = 300;
|
||||||
_buildModeField.RegisterValueChangedCallback(evt =>
|
_buildModeField.RegisterValueChangedCallback(evt =>
|
||||||
{
|
{
|
||||||
|
AssetBundleBuilderSettingData.IsDirty = true;
|
||||||
AssetBundleBuilderSettingData.Setting.BuildMode = (EBuildMode)_buildModeField.value;
|
AssetBundleBuilderSettingData.Setting.BuildMode = (EBuildMode)_buildModeField.value;
|
||||||
RefreshWindow();
|
RefreshWindow();
|
||||||
});
|
});
|
||||||
@@ -78,6 +101,7 @@ namespace YooAsset.Editor
|
|||||||
_buildinTagsField.SetValueWithoutNotify(AssetBundleBuilderSettingData.Setting.BuildTags);
|
_buildinTagsField.SetValueWithoutNotify(AssetBundleBuilderSettingData.Setting.BuildTags);
|
||||||
_buildinTagsField.RegisterValueChangedCallback(evt =>
|
_buildinTagsField.RegisterValueChangedCallback(evt =>
|
||||||
{
|
{
|
||||||
|
AssetBundleBuilderSettingData.IsDirty = true;
|
||||||
AssetBundleBuilderSettingData.Setting.BuildTags = _buildinTagsField.value;
|
AssetBundleBuilderSettingData.Setting.BuildTags = _buildinTagsField.value;
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -91,6 +115,7 @@ namespace YooAsset.Editor
|
|||||||
_encryptionField.style.width = 300;
|
_encryptionField.style.width = 300;
|
||||||
_encryptionField.RegisterValueChangedCallback(evt =>
|
_encryptionField.RegisterValueChangedCallback(evt =>
|
||||||
{
|
{
|
||||||
|
AssetBundleBuilderSettingData.IsDirty = true;
|
||||||
AssetBundleBuilderSettingData.Setting.EncyptionClassName = _encryptionField.value;
|
AssetBundleBuilderSettingData.Setting.EncyptionClassName = _encryptionField.value;
|
||||||
});
|
});
|
||||||
encryptionContainer.Add(_encryptionField);
|
encryptionContainer.Add(_encryptionField);
|
||||||
@@ -110,6 +135,7 @@ namespace YooAsset.Editor
|
|||||||
_compressionField.style.width = 300;
|
_compressionField.style.width = 300;
|
||||||
_compressionField.RegisterValueChangedCallback(evt =>
|
_compressionField.RegisterValueChangedCallback(evt =>
|
||||||
{
|
{
|
||||||
|
AssetBundleBuilderSettingData.IsDirty = true;
|
||||||
AssetBundleBuilderSettingData.Setting.CompressOption = (ECompressOption)_compressionField.value;
|
AssetBundleBuilderSettingData.Setting.CompressOption = (ECompressOption)_compressionField.value;
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -118,6 +144,7 @@ namespace YooAsset.Editor
|
|||||||
_appendExtensionToggle.SetValueWithoutNotify(AssetBundleBuilderSettingData.Setting.AppendExtension);
|
_appendExtensionToggle.SetValueWithoutNotify(AssetBundleBuilderSettingData.Setting.AppendExtension);
|
||||||
_appendExtensionToggle.RegisterValueChangedCallback(evt =>
|
_appendExtensionToggle.RegisterValueChangedCallback(evt =>
|
||||||
{
|
{
|
||||||
|
AssetBundleBuilderSettingData.IsDirty = true;
|
||||||
AssetBundleBuilderSettingData.Setting.AppendExtension = _appendExtensionToggle.value;
|
AssetBundleBuilderSettingData.Setting.AppendExtension = _appendExtensionToggle.value;
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -134,7 +161,24 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
public void OnDestroy()
|
public void OnDestroy()
|
||||||
{
|
{
|
||||||
AssetBundleBuilderSettingData.SaveFile();
|
if(AssetBundleBuilderSettingData.IsDirty)
|
||||||
|
AssetBundleBuilderSettingData.SaveFile();
|
||||||
|
}
|
||||||
|
public void Update()
|
||||||
|
{
|
||||||
|
if(_saveButton != null)
|
||||||
|
{
|
||||||
|
if(AssetBundleBuilderSettingData.IsDirty)
|
||||||
|
{
|
||||||
|
if (_saveButton.enabledSelf == false)
|
||||||
|
_saveButton.SetEnabled(true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(_saveButton.enabledSelf)
|
||||||
|
_saveButton.SetEnabled(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RefreshWindow()
|
private void RefreshWindow()
|
||||||
@@ -146,6 +190,10 @@ namespace YooAsset.Editor
|
|||||||
_compressionField.SetEnabled(enableElement);
|
_compressionField.SetEnabled(enableElement);
|
||||||
_appendExtensionToggle.SetEnabled(enableElement);
|
_appendExtensionToggle.SetEnabled(enableElement);
|
||||||
}
|
}
|
||||||
|
private void SaveBtn_clicked()
|
||||||
|
{
|
||||||
|
AssetBundleBuilderSettingData.SaveFile();
|
||||||
|
}
|
||||||
private void BuildButton_clicked()
|
private void BuildButton_clicked()
|
||||||
{
|
{
|
||||||
var buildMode = AssetBundleBuilderSettingData.Setting.BuildMode;
|
var buildMode = AssetBundleBuilderSettingData.Setting.BuildMode;
|
||||||
@@ -165,23 +213,28 @@ namespace YooAsset.Editor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void ExecuteBuild()
|
private void ExecuteBuild()
|
||||||
{
|
{
|
||||||
var buildMode = (EBuildMode)_buildModeField.value;
|
|
||||||
|
|
||||||
string defaultOutputRoot = AssetBundleBuilderHelper.GetDefaultOutputRoot();
|
string defaultOutputRoot = AssetBundleBuilderHelper.GetDefaultOutputRoot();
|
||||||
BuildParameters buildParameters = new BuildParameters();
|
BuildParameters buildParameters = new BuildParameters();
|
||||||
buildParameters.OutputRoot = defaultOutputRoot;
|
buildParameters.OutputRoot = defaultOutputRoot;
|
||||||
buildParameters.BuildTarget = _buildTarget;
|
buildParameters.BuildTarget = _buildTarget;
|
||||||
buildParameters.BuildMode = buildMode;
|
buildParameters.BuildPipeline = AssetBundleBuilderSettingData.Setting.BuildPipeline;
|
||||||
buildParameters.BuildVersion = _buildVersionField.value;
|
buildParameters.BuildMode = AssetBundleBuilderSettingData.Setting.BuildMode;
|
||||||
buildParameters.BuildinTags = _buildinTagsField.value;
|
buildParameters.BuildVersion = AssetBundleBuilderSettingData.Setting.BuildVersion;
|
||||||
|
buildParameters.BuildinTags = AssetBundleBuilderSettingData.Setting.BuildTags;
|
||||||
buildParameters.VerifyBuildingResult = true;
|
buildParameters.VerifyBuildingResult = true;
|
||||||
buildParameters.EnableAddressable = AssetBundleCollectorSettingData.Setting.EnableAddressable;
|
buildParameters.EnableAddressable = AssetBundleCollectorSettingData.Setting.EnableAddressable;
|
||||||
buildParameters.AppendFileExtension = _appendExtensionToggle.value;
|
buildParameters.AppendFileExtension = AssetBundleBuilderSettingData.Setting.AppendExtension;
|
||||||
buildParameters.CopyBuildinTagFiles = buildMode == EBuildMode.ForceRebuild;
|
buildParameters.CopyBuildinTagFiles = AssetBundleBuilderSettingData.Setting.BuildMode == EBuildMode.ForceRebuild;
|
||||||
buildParameters.EncryptionServices = CreateEncryptionServicesInstance();
|
buildParameters.EncryptionServices = CreateEncryptionServicesInstance();
|
||||||
buildParameters.CompressOption = (ECompressOption)_compressionField.value;
|
buildParameters.CompressOption = AssetBundleBuilderSettingData.Setting.CompressOption;
|
||||||
|
|
||||||
AssetBundleBuilder builder = new AssetBundleBuilder();
|
if (AssetBundleBuilderSettingData.Setting.BuildPipeline == EBuildPipeline.ScriptableBuildPipeline)
|
||||||
|
{
|
||||||
|
buildParameters.SBPParameters = new BuildParameters.SBPBuildParameters();
|
||||||
|
buildParameters.SBPParameters.WriteLinkXML = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
var builder = new AssetBundleBuilder();
|
||||||
bool succeed = builder.Run(buildParameters);
|
bool succeed = builder.Run(buildParameters);
|
||||||
if (succeed)
|
if (succeed)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../UIElementsSchema/UIElements.xsd" editor-extension-mode="True">
|
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../UIElementsSchema/UIElements.xsd" editor-extension-mode="True">
|
||||||
<uie:Toolbar name="Toolbar" style="display: flex;" />
|
<uie:Toolbar name="Toolbar" style="display: flex; flex-direction: row-reverse;">
|
||||||
|
<ui:Button text="Save" display-tooltip-when-elided="true" name="SaveButton" style="background-color: rgb(56, 147, 58);" />
|
||||||
|
</uie:Toolbar>
|
||||||
<ui:VisualElement name="BuildContainer">
|
<ui:VisualElement name="BuildContainer">
|
||||||
<ui:TextField picking-mode="Ignore" label="Build Output" name="BuildOutput" />
|
<ui:TextField picking-mode="Ignore" label="Build Output" name="BuildOutput" />
|
||||||
<uie:IntegerField label="Build Version" value="0" name="BuildVersion" />
|
<uie:IntegerField label="Build Version" value="0" name="BuildVersion" />
|
||||||
|
<uie:EnumField label="Build Pipeline" name="BuildPipeline" />
|
||||||
<uie:EnumField label="Build Mode" name="BuildMode" />
|
<uie:EnumField label="Build Mode" name="BuildMode" />
|
||||||
<ui:VisualElement name="EncryptionContainer" style="height: 24px;" />
|
<ui:VisualElement name="EncryptionContainer" style="height: 24px;" />
|
||||||
<uie:EnumField label="Compression" value="Center" name="Compression" />
|
<uie:EnumField label="Compression" value="Center" name="Compression" />
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 添加资源包的分类标签
|
/// 添加资源包的分类标签
|
||||||
/// 说明:传染算法统计到的分类标签
|
/// 说明:传染算法统计到的分类标签
|
||||||
|
|||||||
@@ -9,6 +9,23 @@ namespace YooAsset.Editor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class BuildParameters
|
public class BuildParameters
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// SBP构建参数
|
||||||
|
/// </summary>
|
||||||
|
public class SBPBuildParameters
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 生成代码防裁剪配置
|
||||||
|
/// </summary>
|
||||||
|
public bool WriteLinkXML = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 可编程构建管线的参数
|
||||||
|
/// </summary>
|
||||||
|
public SBPBuildParameters SBPParameters;
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 输出的根目录
|
/// 输出的根目录
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -19,6 +36,11 @@ namespace YooAsset.Editor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public BuildTarget BuildTarget;
|
public BuildTarget BuildTarget;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 构建管线
|
||||||
|
/// </summary>
|
||||||
|
public EBuildPipeline BuildPipeline;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 构建模式
|
/// 构建模式
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -86,4 +108,6 @@ namespace YooAsset.Editor
|
|||||||
return StringUtility.StringToStringList(BuildinTags, ';');
|
return StringUtility.StringToStringList(BuildinTags, ';');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -40,19 +40,19 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取构建选项
|
/// 获取内置构建管线的构建选项
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public BuildAssetBundleOptions GetPipelineBuildOptions()
|
public BuildAssetBundleOptions GetPipelineBuildOptions()
|
||||||
{
|
{
|
||||||
// For the new build system, unity always need BuildAssetBundleOptions.CollectDependencies and BuildAssetBundleOptions.DeterministicAssetBundle
|
// For the new build system, unity always need BuildAssetBundleOptions.CollectDependencies and BuildAssetBundleOptions.DeterministicAssetBundle
|
||||||
// 除非设置ForceRebuildAssetBundle标记,否则会进行增量打包
|
// 除非设置ForceRebuildAssetBundle标记,否则会进行增量打包
|
||||||
|
|
||||||
BuildAssetBundleOptions opt = BuildAssetBundleOptions.None;
|
|
||||||
opt |= BuildAssetBundleOptions.StrictMode; //Do not allow the build to succeed if any errors are reporting during it.
|
|
||||||
|
|
||||||
if (Parameters.BuildMode == EBuildMode.SimulateBuild)
|
if (Parameters.BuildMode == EBuildMode.SimulateBuild)
|
||||||
throw new Exception("Should never get here !");
|
throw new Exception("Should never get here !");
|
||||||
|
|
||||||
|
BuildAssetBundleOptions opt = BuildAssetBundleOptions.None;
|
||||||
|
opt |= BuildAssetBundleOptions.StrictMode; //Do not allow the build to succeed if any errors are reporting during it.
|
||||||
|
|
||||||
if (Parameters.BuildMode == EBuildMode.DryRunBuild)
|
if (Parameters.BuildMode == EBuildMode.DryRunBuild)
|
||||||
{
|
{
|
||||||
opt |= BuildAssetBundleOptions.DryRunBuild;
|
opt |= BuildAssetBundleOptions.DryRunBuild;
|
||||||
@@ -77,6 +77,39 @@ namespace YooAsset.Editor
|
|||||||
return opt;
|
return opt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取可编程构建管线的构建参数
|
||||||
|
/// </summary>
|
||||||
|
public UnityEditor.Build.Pipeline.BundleBuildParameters GetSBPBuildParameters()
|
||||||
|
{
|
||||||
|
if (Parameters.BuildMode == EBuildMode.SimulateBuild)
|
||||||
|
throw new Exception("Should never get here !");
|
||||||
|
|
||||||
|
if (Parameters.BuildMode == EBuildMode.DryRunBuild)
|
||||||
|
throw new Exception($"SBP not support {nameof(EBuildMode.DryRunBuild)} build mode !");
|
||||||
|
|
||||||
|
var targetGroup = BuildPipeline.GetBuildTargetGroup(Parameters.BuildTarget);
|
||||||
|
var buildParams = new UnityEditor.Build.Pipeline.BundleBuildParameters(Parameters.BuildTarget, targetGroup, PipelineOutputDirectory);
|
||||||
|
|
||||||
|
if (Parameters.CompressOption == ECompressOption.Uncompressed)
|
||||||
|
buildParams.BundleCompression = UnityEngine.BuildCompression.Uncompressed;
|
||||||
|
else if (Parameters.CompressOption == ECompressOption.LZMA)
|
||||||
|
buildParams.BundleCompression = UnityEngine.BuildCompression.LZMA;
|
||||||
|
else if (Parameters.CompressOption == ECompressOption.LZ4)
|
||||||
|
buildParams.BundleCompression = UnityEngine.BuildCompression.LZ4;
|
||||||
|
else
|
||||||
|
throw new System.NotImplementedException(Parameters.CompressOption.ToString());
|
||||||
|
|
||||||
|
if (Parameters.BuildMode == EBuildMode.ForceRebuild)
|
||||||
|
buildParams.UseCache = false;
|
||||||
|
if (Parameters.DisableWriteTypeTree)
|
||||||
|
buildParams.ContentBuildFlags |= UnityEditor.Build.Content.ContentBuildFlags.DisableWriteTypeTree;
|
||||||
|
|
||||||
|
buildParams.WriteLinkXML = Parameters.SBPParameters.WriteLinkXML;
|
||||||
|
|
||||||
|
return buildParams;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取构建的耗时(单位:秒)
|
/// 获取构建的耗时(单位:秒)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -8,6 +8,11 @@ namespace YooAsset.Editor
|
|||||||
[Serializable]
|
[Serializable]
|
||||||
public class ReportSummary
|
public class ReportSummary
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// YooAsset版本
|
||||||
|
/// </summary>
|
||||||
|
public string YooVersion;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 引擎版本
|
/// 引擎版本
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -16,7 +21,7 @@ namespace YooAsset.Editor
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 构建时间
|
/// 构建时间
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string BuildTime;
|
public string BuildDate;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 构建耗时(单位:秒)
|
/// 构建耗时(单位:秒)
|
||||||
@@ -28,6 +33,11 @@ namespace YooAsset.Editor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public BuildTarget BuildTarget;
|
public BuildTarget BuildTarget;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 构建管线
|
||||||
|
/// </summary>
|
||||||
|
public EBuildPipeline BuildPipeline;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 构建模式
|
/// 构建模式
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.IO;
|
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
|
|||||||
@@ -0,0 +1,82 @@
|
|||||||
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
using UnityEditor.Build.Pipeline;
|
||||||
|
using UnityEditor.Build.Pipeline.Interfaces;
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
[TaskAttribute("资源构建内容打包")]
|
||||||
|
public class TaskBuilding_SBP : IBuildTask
|
||||||
|
{
|
||||||
|
public class SBPBuildResultContext : IContextObject
|
||||||
|
{
|
||||||
|
public IBundleBuildResults Results;
|
||||||
|
}
|
||||||
|
|
||||||
|
void IBuildTask.Run(BuildContext context)
|
||||||
|
{
|
||||||
|
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||||
|
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||||
|
|
||||||
|
// 模拟构建模式下跳过引擎构建
|
||||||
|
var buildMode = buildParametersContext.Parameters.BuildMode;
|
||||||
|
if (buildMode == EBuildMode.SimulateBuild)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// 构建内容
|
||||||
|
var buildContent = new BundleBuildContent(buildMapContext.GetPipelineBuilds());
|
||||||
|
|
||||||
|
// 开始构建
|
||||||
|
IBundleBuildResults buildResults;
|
||||||
|
var buildParameters = buildParametersContext.GetSBPBuildParameters();
|
||||||
|
var taskList = DefaultBuildTasks.Create(DefaultBuildTasks.Preset.AssetBundleBuiltInShaderExtraction);
|
||||||
|
ReturnCode exitCode = ContentPipeline.BuildAssetBundles(buildParameters, buildContent, out buildResults, taskList);
|
||||||
|
if (exitCode < 0)
|
||||||
|
{
|
||||||
|
throw new Exception($"构建过程中发生错误 : {exitCode}");
|
||||||
|
}
|
||||||
|
|
||||||
|
BuildRunner.Log("Unity引擎打包成功!");
|
||||||
|
SBPBuildResultContext buildResultContext = new SBPBuildResultContext();
|
||||||
|
buildResultContext.Results = buildResults;
|
||||||
|
context.SetContextObject(buildResultContext);
|
||||||
|
|
||||||
|
// 添加Unity内置资源包信息
|
||||||
|
if (buildResults.BundleInfos.Keys.Any(t => t == YooAssetSettings.UnityBuiltInShadersBundleName))
|
||||||
|
{
|
||||||
|
BuildBundleInfo builtInBundleInfo = new BuildBundleInfo(YooAssetSettings.UnityBuiltInShadersBundleName);
|
||||||
|
buildMapContext.BundleInfos.Add(builtInBundleInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 拷贝原生文件
|
||||||
|
if (buildMode == EBuildMode.ForceRebuild || buildMode == EBuildMode.IncrementalBuild)
|
||||||
|
{
|
||||||
|
CopyRawBundle(buildMapContext, buildParametersContext);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 拷贝原生文件
|
||||||
|
/// </summary>
|
||||||
|
private void CopyRawBundle(BuildMapContext buildMapContext, BuildParametersContext buildParametersContext)
|
||||||
|
{
|
||||||
|
foreach (var bundleInfo in buildMapContext.BundleInfos)
|
||||||
|
{
|
||||||
|
if (bundleInfo.IsRawFile)
|
||||||
|
{
|
||||||
|
string dest = $"{buildParametersContext.PipelineOutputDirectory}/{bundleInfo.BundleName}";
|
||||||
|
foreach (var buildAsset in bundleInfo.BuildinAssets)
|
||||||
|
{
|
||||||
|
if (buildAsset.IsRawAsset)
|
||||||
|
EditorTools.CopyFile(buildAsset.AssetPath, dest, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 1af5fed7e9f83174d868c12b41c4a79e
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -1,8 +1,11 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.Linq;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
using UnityEditor.Build.Pipeline;
|
||||||
|
using UnityEditor.Build.Pipeline.Interfaces;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
[TaskAttribute("创建补丁清单文件")]
|
[TaskAttribute("创建补丁清单文件")]
|
||||||
@@ -10,18 +13,17 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
{
|
{
|
||||||
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
CreatePatchManifestFile(context);
|
||||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
|
||||||
var encryptionContext = context.GetContextObject<TaskEncryption.EncryptionContext>();
|
|
||||||
CreatePatchManifestFile(buildParameters, buildMapContext, encryptionContext);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 创建补丁清单文件到输出目录
|
/// 创建补丁清单文件到输出目录
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void CreatePatchManifestFile(BuildParametersContext buildParameters, BuildMapContext buildMapContext,
|
private void CreatePatchManifestFile(BuildContext context)
|
||||||
TaskEncryption.EncryptionContext encryptionContext)
|
|
||||||
{
|
{
|
||||||
|
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
||||||
|
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||||
|
var encryptionContext = context.GetContextObject<TaskEncryption.EncryptionContext>();
|
||||||
int resourceVersion = buildParameters.Parameters.BuildVersion;
|
int resourceVersion = buildParameters.Parameters.BuildVersion;
|
||||||
|
|
||||||
// 创建新补丁清单
|
// 创建新补丁清单
|
||||||
@@ -32,6 +34,13 @@ namespace YooAsset.Editor
|
|||||||
patchManifest.BundleList = GetAllPatchBundle(buildParameters, buildMapContext, encryptionContext);
|
patchManifest.BundleList = GetAllPatchBundle(buildParameters, buildMapContext, encryptionContext);
|
||||||
patchManifest.AssetList = GetAllPatchAsset(buildParameters, buildMapContext, patchManifest);
|
patchManifest.AssetList = GetAllPatchAsset(buildParameters, buildMapContext, patchManifest);
|
||||||
|
|
||||||
|
// 更新Unity内置资源包的引用关系
|
||||||
|
if (buildParameters.Parameters.BuildPipeline == EBuildPipeline.ScriptableBuildPipeline)
|
||||||
|
{
|
||||||
|
var buildResultContext = context.GetContextObject<TaskBuilding_SBP.SBPBuildResultContext>();
|
||||||
|
UpdateBuiltInBundleReference(patchManifest, buildResultContext.Results);
|
||||||
|
}
|
||||||
|
|
||||||
// 创建补丁清单文件
|
// 创建补丁清单文件
|
||||||
string manifestFilePath = $"{buildParameters.PipelineOutputDirectory}/{YooAssetSettingsData.GetPatchManifestFileName(resourceVersion)}";
|
string manifestFilePath = $"{buildParameters.PipelineOutputDirectory}/{YooAssetSettingsData.GetPatchManifestFileName(resourceVersion)}";
|
||||||
BuildRunner.Log($"创建补丁清单文件:{manifestFilePath}");
|
BuildRunner.Log($"创建补丁清单文件:{manifestFilePath}");
|
||||||
@@ -172,5 +181,45 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
throw new Exception($"Not found bundle name : {bundleName}");
|
throw new Exception($"Not found bundle name : {bundleName}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 更新Unity内置资源包的引用关系
|
||||||
|
/// </summary>
|
||||||
|
private void UpdateBuiltInBundleReference(PatchManifest patchManifest, IBundleBuildResults buildResults)
|
||||||
|
{
|
||||||
|
// 获取所有依赖内置资源包的资源包列表
|
||||||
|
List<string> builtInBundleReferenceList = new List<string>();
|
||||||
|
foreach (var valuePair in buildResults.BundleInfos)
|
||||||
|
{
|
||||||
|
if (valuePair.Value.Dependencies.Any(t => t == YooAssetSettings.UnityBuiltInShadersBundleName))
|
||||||
|
builtInBundleReferenceList.Add(valuePair.Key);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检测依赖交集并更新依赖ID
|
||||||
|
int builtInBundleId = patchManifest.BundleList.Count - 1;
|
||||||
|
foreach (var patchAsset in patchManifest.AssetList)
|
||||||
|
{
|
||||||
|
List<string> dependBundles = GetPatchAssetAllDependBundles(patchManifest, patchAsset);
|
||||||
|
List<string> conflictAssetPathList = dependBundles.Intersect(builtInBundleReferenceList).ToList();
|
||||||
|
if (conflictAssetPathList.Count > 0)
|
||||||
|
{
|
||||||
|
List<int> newDependIDs = new List<int>(patchAsset.DependIDs);
|
||||||
|
newDependIDs.Add(builtInBundleId);
|
||||||
|
patchAsset.DependIDs = newDependIDs.ToArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private List<string> GetPatchAssetAllDependBundles(PatchManifest patchManifest, PatchAsset patchAsset)
|
||||||
|
{
|
||||||
|
List<string> result = new List<string>();
|
||||||
|
string mainBundle = patchManifest.BundleList[patchAsset.BundleID].BundleName;
|
||||||
|
result.Add(mainBundle);
|
||||||
|
foreach (var dependID in patchAsset.DependIDs)
|
||||||
|
{
|
||||||
|
string dependBundle = patchManifest.BundleList[dependID].BundleName;
|
||||||
|
result.Add(dependBundle);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -54,18 +54,38 @@ namespace YooAsset.Editor
|
|||||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 拷贝UnityManifest序列化文件
|
if (buildParameters.Parameters.BuildPipeline == EBuildPipeline.ScriptableBuildPipeline)
|
||||||
{
|
{
|
||||||
string sourcePath = $"{buildParameters.PipelineOutputDirectory}/{YooAssetSettingsData.Setting.UnityManifestFileName}";
|
// 拷贝构建日志
|
||||||
string destPath = $"{packageDirectory}/{YooAssetSettingsData.Setting.UnityManifestFileName}";
|
{
|
||||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
string sourcePath = $"{buildParameters.PipelineOutputDirectory}/buildlogtep.json";
|
||||||
}
|
string destPath = $"{packageDirectory}/buildlogtep.json";
|
||||||
|
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||||
|
}
|
||||||
|
|
||||||
// 拷贝UnityManifest文本文件
|
// 拷贝代码防裁剪配置
|
||||||
|
if (buildParameters.Parameters.SBPParameters.WriteLinkXML)
|
||||||
|
{
|
||||||
|
string sourcePath = $"{buildParameters.PipelineOutputDirectory}/link.xml";
|
||||||
|
string destPath = $"{packageDirectory}/link.xml";
|
||||||
|
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
string sourcePath = $"{buildParameters.PipelineOutputDirectory}/{YooAssetSettingsData.Setting.UnityManifestFileName}.manifest";
|
// 拷贝UnityManifest序列化文件
|
||||||
string destPath = $"{packageDirectory}/{YooAssetSettingsData.Setting.UnityManifestFileName}.manifest";
|
{
|
||||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
string sourcePath = $"{buildParameters.PipelineOutputDirectory}/{YooAssetSettingsData.Setting.UnityManifestFileName}";
|
||||||
|
string destPath = $"{packageDirectory}/{YooAssetSettingsData.Setting.UnityManifestFileName}";
|
||||||
|
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 拷贝UnityManifest文本文件
|
||||||
|
{
|
||||||
|
string sourcePath = $"{buildParameters.PipelineOutputDirectory}/{YooAssetSettingsData.Setting.UnityManifestFileName}.manifest";
|
||||||
|
string destPath = $"{packageDirectory}/{YooAssetSettingsData.Setting.UnityManifestFileName}.manifest";
|
||||||
|
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 拷贝所有补丁文件
|
// 拷贝所有补丁文件
|
||||||
|
|||||||
@@ -29,14 +29,20 @@ namespace YooAsset.Editor
|
|||||||
private void CreateReportFile(BuildParametersContext buildParameters, BuildMapContext buildMapContext)
|
private void CreateReportFile(BuildParametersContext buildParameters, BuildMapContext buildMapContext)
|
||||||
{
|
{
|
||||||
PatchManifest patchManifest = AssetBundleBuilderHelper.LoadPatchManifestFile(buildParameters.PipelineOutputDirectory, buildParameters.Parameters.BuildVersion);
|
PatchManifest patchManifest = AssetBundleBuilderHelper.LoadPatchManifestFile(buildParameters.PipelineOutputDirectory, buildParameters.Parameters.BuildVersion);
|
||||||
BuildReport buildReport = new BuildReport();
|
BuildReport buildReport = new BuildReport();
|
||||||
|
|
||||||
// 概述信息
|
// 概述信息
|
||||||
{
|
{
|
||||||
|
#if UNITY_2019_4_OR_NEWER
|
||||||
|
UnityEditor.PackageManager.PackageInfo packageInfo = UnityEditor.PackageManager.PackageInfo.FindForAssembly(typeof(BuildReport).Assembly);
|
||||||
|
if (packageInfo != null)
|
||||||
|
buildReport.Summary.YooVersion = packageInfo.version;
|
||||||
|
#endif
|
||||||
buildReport.Summary.UnityVersion = UnityEngine.Application.unityVersion;
|
buildReport.Summary.UnityVersion = UnityEngine.Application.unityVersion;
|
||||||
buildReport.Summary.BuildTime = DateTime.Now.ToString();
|
buildReport.Summary.BuildDate = DateTime.Now.ToString();
|
||||||
buildReport.Summary.BuildSeconds = (int)buildParameters.GetBuildingSeconds();
|
buildReport.Summary.BuildSeconds = (int)buildParameters.GetBuildingSeconds();
|
||||||
buildReport.Summary.BuildTarget = buildParameters.Parameters.BuildTarget;
|
buildReport.Summary.BuildTarget = buildParameters.Parameters.BuildTarget;
|
||||||
|
buildReport.Summary.BuildPipeline = buildParameters.Parameters.BuildPipeline;
|
||||||
buildReport.Summary.BuildMode = buildParameters.Parameters.BuildMode;
|
buildReport.Summary.BuildMode = buildParameters.Parameters.BuildMode;
|
||||||
buildReport.Summary.BuildVersion = buildParameters.Parameters.BuildVersion;
|
buildReport.Summary.BuildVersion = buildParameters.Parameters.BuildVersion;
|
||||||
buildReport.Summary.BuildinTags = buildParameters.Parameters.BuildinTags;
|
buildReport.Summary.BuildinTags = buildParameters.Parameters.BuildinTags;
|
||||||
|
|||||||
@@ -26,6 +26,17 @@ namespace YooAsset.Editor
|
|||||||
if (string.IsNullOrEmpty(buildParameters.PipelineOutputDirectory))
|
if (string.IsNullOrEmpty(buildParameters.PipelineOutputDirectory))
|
||||||
throw new Exception("输出目录不能为空");
|
throw new Exception("输出目录不能为空");
|
||||||
|
|
||||||
|
// 检测当前是否正在构建资源包
|
||||||
|
if (BuildPipeline.isBuildingPlayer)
|
||||||
|
throw new Exception("当前正在构建资源包,请结束后再试");
|
||||||
|
|
||||||
|
// 检测是否有未保存场景
|
||||||
|
if (EditorTools.HasDirtyScenes())
|
||||||
|
throw new Exception("检测到未保存的场景文件");
|
||||||
|
|
||||||
|
// 保存改动的资源
|
||||||
|
AssetDatabase.SaveAssets();
|
||||||
|
|
||||||
// 增量更新时候的必要检测
|
// 增量更新时候的必要检测
|
||||||
var buildMode = buildParameters.Parameters.BuildMode;
|
var buildMode = buildParameters.Parameters.BuildMode;
|
||||||
if (buildMode == EBuildMode.IncrementalBuild)
|
if (buildMode == EBuildMode.IncrementalBuild)
|
||||||
|
|||||||
@@ -37,53 +37,21 @@ namespace YooAsset.Editor
|
|||||||
string[] buildedBundles = unityManifest.GetAllAssetBundles();
|
string[] buildedBundles = unityManifest.GetAllAssetBundles();
|
||||||
|
|
||||||
// 1. 过滤掉原生Bundle
|
// 1. 过滤掉原生Bundle
|
||||||
List<BuildBundleInfo> expectBundles = new List<BuildBundleInfo>(buildedBundles.Length);
|
string[] expectBundles = buildMapContext.BundleInfos.Where(t => t.IsRawFile == false).Select(t => t.BundleName).ToArray();
|
||||||
foreach(var bundleInfo in buildMapContext.BundleInfos)
|
|
||||||
{
|
|
||||||
if (bundleInfo.IsRawFile == false)
|
|
||||||
expectBundles.Add(bundleInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 2. 验证数量
|
// 2. 验证Bundle
|
||||||
if (buildedBundles.Length != expectBundles.Count)
|
List<string> intersectBundleList = buildedBundles.Except(expectBundles).ToList();
|
||||||
|
if (intersectBundleList.Count > 0)
|
||||||
{
|
{
|
||||||
Debug.LogWarning($"构建过程中可能存在无效的资源,导致和预期构建的Bundle数量不一致!");
|
foreach (var intersectBundle in intersectBundleList)
|
||||||
}
|
|
||||||
|
|
||||||
// 3. 正向验证Bundle
|
|
||||||
foreach (var bundleName in buildedBundles)
|
|
||||||
{
|
|
||||||
if (buildMapContext.IsContainsBundle(bundleName) == false)
|
|
||||||
{
|
{
|
||||||
throw new Exception($"Should never get here !");
|
Debug.LogWarning($"差异资源包: {intersectBundle}");
|
||||||
}
|
}
|
||||||
|
throw new System.Exception("存在差异资源包!请查看警告信息!");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4. 反向验证Bundle
|
// 3. 验证Asset
|
||||||
bool isPass = true;
|
bool isPass = true;
|
||||||
foreach (var expectBundle in expectBundles)
|
|
||||||
{
|
|
||||||
bool isMatch = false;
|
|
||||||
foreach (var buildedBundle in buildedBundles)
|
|
||||||
{
|
|
||||||
if (buildedBundle == expectBundle.BundleName)
|
|
||||||
{
|
|
||||||
isMatch = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (isMatch == false)
|
|
||||||
{
|
|
||||||
isPass = false;
|
|
||||||
Debug.LogWarning($"没有找到预期构建的Bundle文件 : {expectBundle.BundleName}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(isPass == false)
|
|
||||||
{
|
|
||||||
throw new Exception("构建结果验证没有通过,请参考警告日志!");
|
|
||||||
}
|
|
||||||
|
|
||||||
// 5. 验证Asset
|
|
||||||
var buildMode = buildParameters.Parameters.BuildMode;
|
var buildMode = buildParameters.Parameters.BuildMode;
|
||||||
if (buildMode == EBuildMode.ForceRebuild || buildMode == EBuildMode.IncrementalBuild)
|
if (buildMode == EBuildMode.ForceRebuild || buildMode == EBuildMode.IncrementalBuild)
|
||||||
{
|
{
|
||||||
@@ -137,7 +105,6 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 卸载所有加载的Bundle
|
|
||||||
BuildRunner.Log("构建结果验证成功!");
|
BuildRunner.Log("构建结果验证成功!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,60 @@
|
|||||||
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
using System.IO;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEditor.Build.Pipeline.Interfaces;
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
[TaskAttribute("验证构建结果")]
|
||||||
|
public class TaskVerifyBuildResult_SBP : IBuildTask
|
||||||
|
{
|
||||||
|
void IBuildTask.Run(BuildContext context)
|
||||||
|
{
|
||||||
|
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||||
|
|
||||||
|
// 模拟构建模式下跳过验证
|
||||||
|
if (buildParametersContext.Parameters.BuildMode == EBuildMode.SimulateBuild)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// 验证构建结果
|
||||||
|
if (buildParametersContext.Parameters.VerifyBuildingResult)
|
||||||
|
{
|
||||||
|
var buildResultContext = context.GetContextObject<TaskBuilding_SBP.SBPBuildResultContext>();
|
||||||
|
VerifyingBuildingResult(context, buildResultContext.Results);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 验证构建结果
|
||||||
|
/// </summary>
|
||||||
|
private void VerifyingBuildingResult(BuildContext context, IBundleBuildResults buildResults)
|
||||||
|
{
|
||||||
|
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
||||||
|
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||||
|
|
||||||
|
// 1. 移除特定Bundle
|
||||||
|
List<string> buildedBundles = buildResults.BundleInfos.Keys.ToList();
|
||||||
|
buildedBundles.Remove(YooAssetSettings.UnityBuiltInShadersBundleName);
|
||||||
|
|
||||||
|
// 2. 过滤掉原生Bundle
|
||||||
|
List<string> expectBundles = buildMapContext.BundleInfos.Where(t => t.IsRawFile == false).Select(t => t.BundleName).ToList();
|
||||||
|
|
||||||
|
// 3. 验证Bundle
|
||||||
|
List<string> intersectBundleList = buildedBundles.Except(expectBundles).ToList();
|
||||||
|
if (intersectBundleList.Count > 0)
|
||||||
|
{
|
||||||
|
foreach (var intersectBundle in intersectBundleList)
|
||||||
|
{
|
||||||
|
Debug.LogWarning($"差异资源包: {intersectBundle}");
|
||||||
|
}
|
||||||
|
throw new System.Exception("存在差异资源包!请查看警告信息!");
|
||||||
|
}
|
||||||
|
|
||||||
|
BuildRunner.Log("构建结果验证成功!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 16aa7c2c37209a043b4f33d7854047c6
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
19
Assets/YooAsset/Editor/AssetBundleBuilder/EBuildPipeline.cs
Normal file
19
Assets/YooAsset/Editor/AssetBundleBuilder/EBuildPipeline.cs
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 构建管线类型
|
||||||
|
/// </summary>
|
||||||
|
public enum EBuildPipeline
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 传统内置构建管线
|
||||||
|
/// </summary>
|
||||||
|
BuiltinBuildPipeline,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 可编程构建管线
|
||||||
|
/// </summary>
|
||||||
|
ScriptableBuildPipeline,
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: e53e56a0f6b01dd4c933249d2bda8d78
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -180,7 +180,15 @@ namespace YooAsset.Editor
|
|||||||
private bool IsValidateAsset(string assetPath)
|
private bool IsValidateAsset(string assetPath)
|
||||||
{
|
{
|
||||||
if (assetPath.StartsWith("Assets/") == false && assetPath.StartsWith("Packages/") == false)
|
if (assetPath.StartsWith("Assets/") == false && assetPath.StartsWith("Packages/") == false)
|
||||||
|
{
|
||||||
|
UnityEngine.Debug.LogError($"Invalid asset path : {assetPath}");
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
if (assetPath.Contains("/Gizmos/"))
|
||||||
|
{
|
||||||
|
UnityEngine.Debug.LogWarning($"Cannot pack gizmos asset : {assetPath}");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (AssetDatabase.IsValidFolder(assetPath))
|
if (AssetDatabase.IsValidFolder(assetPath))
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ namespace YooAsset.Editor
|
|||||||
window.minSize = new Vector2(800, 600);
|
window.minSize = new Vector2(800, 600);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Button _saveButton;
|
||||||
private List<string> _collectorTypeList;
|
private List<string> _collectorTypeList;
|
||||||
private List<string> _activeRuleList;
|
private List<string> _activeRuleList;
|
||||||
private List<string> _addressRuleList;
|
private List<string> _addressRuleList;
|
||||||
@@ -69,6 +70,10 @@ namespace YooAsset.Editor
|
|||||||
var importBtn = root.Q<Button>("ImportButton");
|
var importBtn = root.Q<Button>("ImportButton");
|
||||||
importBtn.clicked += ImportBtn_clicked;
|
importBtn.clicked += ImportBtn_clicked;
|
||||||
|
|
||||||
|
// 配置保存按钮
|
||||||
|
_saveButton = root.Q<Button>("SaveButton");
|
||||||
|
_saveButton.clicked += SaveBtn_clicked;
|
||||||
|
|
||||||
// 公共设置相关
|
// 公共设置相关
|
||||||
_enableAddressableToogle = root.Q<Toggle>("EnableAddressable");
|
_enableAddressableToogle = root.Q<Toggle>("EnableAddressable");
|
||||||
_enableAddressableToogle.RegisterValueChangedCallback(evt =>
|
_enableAddressableToogle.RegisterValueChangedCallback(evt =>
|
||||||
@@ -193,6 +198,22 @@ namespace YooAsset.Editor
|
|||||||
if (AssetBundleCollectorSettingData.IsDirty)
|
if (AssetBundleCollectorSettingData.IsDirty)
|
||||||
AssetBundleCollectorSettingData.SaveFile();
|
AssetBundleCollectorSettingData.SaveFile();
|
||||||
}
|
}
|
||||||
|
public void Update()
|
||||||
|
{
|
||||||
|
if (_saveButton != null)
|
||||||
|
{
|
||||||
|
if (AssetBundleCollectorSettingData.IsDirty)
|
||||||
|
{
|
||||||
|
if (_saveButton.enabledSelf == false)
|
||||||
|
_saveButton.SetEnabled(true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (_saveButton.enabledSelf)
|
||||||
|
_saveButton.SetEnabled(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void RefreshWindow()
|
private void RefreshWindow()
|
||||||
{
|
{
|
||||||
@@ -221,6 +242,10 @@ namespace YooAsset.Editor
|
|||||||
RefreshWindow();
|
RefreshWindow();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
private void SaveBtn_clicked()
|
||||||
|
{
|
||||||
|
AssetBundleCollectorSettingData.SaveFile();
|
||||||
|
}
|
||||||
|
|
||||||
// 分组列表相关
|
// 分组列表相关
|
||||||
private void FillGroupViewData()
|
private void FillGroupViewData()
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../UIElementsSchema/UIElements.xsd" editor-extension-mode="True">
|
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../UIElementsSchema/UIElements.xsd" editor-extension-mode="True">
|
||||||
<uie:Toolbar name="Toolbar" style="display: flex; flex-direction: row-reverse;">
|
<uie:Toolbar name="Toolbar" style="display: flex; flex-direction: row-reverse;">
|
||||||
|
<ui:Button text="Save" display-tooltip-when-elided="true" name="SaveButton" style="width: 50px; background-color: rgb(56, 147, 58);" />
|
||||||
<ui:Button text="导出" display-tooltip-when-elided="true" name="ExportButton" style="width: 50px; background-color: rgb(56, 147, 58);" />
|
<ui:Button text="导出" display-tooltip-when-elided="true" name="ExportButton" style="width: 50px; background-color: rgb(56, 147, 58);" />
|
||||||
<ui:Button text="导入" display-tooltip-when-elided="true" name="ImportButton" style="width: 50px; background-color: rgb(56, 147, 58);" />
|
<ui:Button text="导入" display-tooltip-when-elided="true" name="ImportButton" style="width: 50px; background-color: rgb(56, 147, 58);" />
|
||||||
</uie:Toolbar>
|
</uie:Toolbar>
|
||||||
|
|||||||
@@ -58,10 +58,13 @@ namespace YooAsset.Editor
|
|||||||
_buildReport = buildReport;
|
_buildReport = buildReport;
|
||||||
|
|
||||||
_items.Clear();
|
_items.Clear();
|
||||||
|
|
||||||
|
_items.Add(new ItemWrapper("YooAsset版本", buildReport.Summary.YooVersion));
|
||||||
_items.Add(new ItemWrapper("引擎版本", buildReport.Summary.UnityVersion));
|
_items.Add(new ItemWrapper("引擎版本", buildReport.Summary.UnityVersion));
|
||||||
_items.Add(new ItemWrapper("构建时间", buildReport.Summary.BuildTime));
|
_items.Add(new ItemWrapper("构建时间", buildReport.Summary.BuildDate));
|
||||||
_items.Add(new ItemWrapper("构建耗时", $"{buildReport.Summary.BuildSeconds}秒"));
|
_items.Add(new ItemWrapper("构建耗时", $"{buildReport.Summary.BuildSeconds}秒"));
|
||||||
_items.Add(new ItemWrapper("构建平台", $"{buildReport.Summary.BuildTarget}"));
|
_items.Add(new ItemWrapper("构建平台", $"{buildReport.Summary.BuildTarget}"));
|
||||||
|
_items.Add(new ItemWrapper("构建管线", $"{buildReport.Summary.BuildPipeline}"));
|
||||||
_items.Add(new ItemWrapper("构建模式", $"{buildReport.Summary.BuildMode}"));
|
_items.Add(new ItemWrapper("构建模式", $"{buildReport.Summary.BuildMode}"));
|
||||||
_items.Add(new ItemWrapper("构建版本", $"{buildReport.Summary.BuildVersion}"));
|
_items.Add(new ItemWrapper("构建版本", $"{buildReport.Summary.BuildVersion}"));
|
||||||
_items.Add(new ItemWrapper("内置资源标签", $"{buildReport.Summary.BuildinTags}"));
|
_items.Add(new ItemWrapper("内置资源标签", $"{buildReport.Summary.BuildinTags}"));
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ using System.IO;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
|
using UnityEditor.SceneManagement;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
@@ -265,6 +266,20 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region SceneUtility
|
||||||
|
public static bool HasDirtyScenes()
|
||||||
|
{
|
||||||
|
var sceneCount = EditorSceneManager.sceneCount;
|
||||||
|
for (var i = 0; i < sceneCount; ++i)
|
||||||
|
{
|
||||||
|
var scene = EditorSceneManager.GetSceneAt(i);
|
||||||
|
if (scene.isDirty)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region 文件
|
#region 文件
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 创建文件所在的目录
|
/// 创建文件所在的目录
|
||||||
|
|||||||
@@ -34,6 +34,8 @@ namespace YooAsset.Editor
|
|||||||
EditorGUILayout.Space();
|
EditorGUILayout.Space();
|
||||||
if (GUILayout.Button("搜集变种", GUILayout.MaxWidth(80)))
|
if (GUILayout.Button("搜集变种", GUILayout.MaxWidth(80)))
|
||||||
{
|
{
|
||||||
|
// 先删除再保存,否则ShaderVariantCollection内容将无法及时刷新
|
||||||
|
AssetDatabase.DeleteAsset(ShaderVariantCollectorSettingData.Setting.SavePath);
|
||||||
ShaderVariantCollector.Run(ShaderVariantCollectorSettingData.Setting.SavePath);
|
ShaderVariantCollector.Run(ShaderVariantCollectorSettingData.Setting.SavePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,9 @@
|
|||||||
"name": "YooAsset.Editor",
|
"name": "YooAsset.Editor",
|
||||||
"rootNamespace": "",
|
"rootNamespace": "",
|
||||||
"references": [
|
"references": [
|
||||||
"YooAsset"
|
"YooAsset",
|
||||||
|
"Unity.ScriptableBuildPipeline",
|
||||||
|
"Unity.ScriptableBuildPipeline.Editor"
|
||||||
],
|
],
|
||||||
"includePlatforms": [
|
"includePlatforms": [
|
||||||
"Editor"
|
"Editor"
|
||||||
|
|||||||
@@ -117,7 +117,11 @@ namespace YooAsset
|
|||||||
if (AssetSystem.DecryptionServices == null)
|
if (AssetSystem.DecryptionServices == null)
|
||||||
throw new Exception($"{nameof(AssetBundleFileLoader)} need {nameof(IDecryptionServices)} : {MainBundleInfo.BundleName}");
|
throw new Exception($"{nameof(AssetBundleFileLoader)} need {nameof(IDecryptionServices)} : {MainBundleInfo.BundleName}");
|
||||||
|
|
||||||
ulong offset = AssetSystem.DecryptionServices.GetFileOffset();
|
DecryptionFileInfo fileInfo = new DecryptionFileInfo();
|
||||||
|
fileInfo.BundleName = MainBundleInfo.BundleName;
|
||||||
|
fileInfo.BundleHash = MainBundleInfo.Hash;
|
||||||
|
fileInfo.BundleCRC = MainBundleInfo.CRC;
|
||||||
|
ulong offset = AssetSystem.DecryptionServices.GetFileOffset(fileInfo);
|
||||||
if (_isWaitForAsyncComplete)
|
if (_isWaitForAsyncComplete)
|
||||||
CacheBundle = AssetBundle.LoadFromFile(_fileLoadPath, 0, offset);
|
CacheBundle = AssetBundle.LoadFromFile(_fileLoadPath, 0, offset);
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -382,7 +382,7 @@ namespace YooAsset
|
|||||||
|
|
||||||
// 忽略APP资源
|
// 忽略APP资源
|
||||||
// 注意:如果是APP资源并且哈希值相同,则不需要下载
|
// 注意:如果是APP资源并且哈希值相同,则不需要下载
|
||||||
if (appPatchManifest.Bundles.TryGetValue(patchBundle.BundleName, out PatchBundle appPatchBundle))
|
if (appPatchManifest.TryGetPatchBundle(patchBundle.BundleName, out PatchBundle appPatchBundle))
|
||||||
{
|
{
|
||||||
if (appPatchBundle.IsBuildin && appPatchBundle.Hash == patchBundle.Hash)
|
if (appPatchBundle.IsBuildin && appPatchBundle.Hash == patchBundle.Hash)
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -203,7 +203,7 @@ namespace YooAsset
|
|||||||
|
|
||||||
// 忽略APP资源
|
// 忽略APP资源
|
||||||
// 注意:如果是APP资源并且哈希值相同,则不需要下载
|
// 注意:如果是APP资源并且哈希值相同,则不需要下载
|
||||||
if (_impl.AppPatchManifest.Bundles.TryGetValue(patchBundle.BundleName, out PatchBundle appPatchBundle))
|
if (_impl.AppPatchManifest.TryGetPatchBundle(patchBundle.BundleName, out PatchBundle appPatchBundle))
|
||||||
{
|
{
|
||||||
if (appPatchBundle.IsBuildin && appPatchBundle.Hash == patchBundle.Hash)
|
if (appPatchBundle.IsBuildin && appPatchBundle.Hash == patchBundle.Hash)
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -42,13 +42,13 @@ namespace YooAsset
|
|||||||
/// 资源包集合(提供BundleName获取PatchBundle)
|
/// 资源包集合(提供BundleName获取PatchBundle)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[NonSerialized]
|
[NonSerialized]
|
||||||
public readonly Dictionary<string, PatchBundle> Bundles = new Dictionary<string, PatchBundle>();
|
public readonly Dictionary<string, PatchBundle> BundleDic = new Dictionary<string, PatchBundle>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源映射集合(提供AssetPath获取PatchAsset)
|
/// 资源映射集合(提供AssetPath获取PatchAsset)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[NonSerialized]
|
[NonSerialized]
|
||||||
public readonly Dictionary<string, PatchAsset> Assets = new Dictionary<string, PatchAsset>();
|
public readonly Dictionary<string, PatchAsset> AssetDic = new Dictionary<string, PatchAsset>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源路径映射集合
|
/// 资源路径映射集合
|
||||||
@@ -117,7 +117,7 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string MappingToAssetPath(string location)
|
public string MappingToAssetPath(string location)
|
||||||
{
|
{
|
||||||
if(string.IsNullOrEmpty(location))
|
if (string.IsNullOrEmpty(location))
|
||||||
{
|
{
|
||||||
YooLogger.Error("Failed to mapping location to asset path, The location is null or empty.");
|
YooLogger.Error("Failed to mapping location to asset path, The location is null or empty.");
|
||||||
return string.Empty;
|
return string.Empty;
|
||||||
@@ -138,18 +138,18 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取资源包名称
|
/// 获取主资源包
|
||||||
/// 注意:传入的资源路径一定合法有效!
|
/// 注意:传入的资源路径一定合法有效!
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string GetBundleName(string assetPath)
|
public PatchBundle GetMainPatchBundle(string assetPath)
|
||||||
{
|
{
|
||||||
if (Assets.TryGetValue(assetPath, out PatchAsset patchAsset))
|
if (AssetDic.TryGetValue(assetPath, out PatchAsset patchAsset))
|
||||||
{
|
{
|
||||||
int bundleID = patchAsset.BundleID;
|
int bundleID = patchAsset.BundleID;
|
||||||
if (bundleID >= 0 && bundleID < BundleList.Count)
|
if (bundleID >= 0 && bundleID < BundleList.Count)
|
||||||
{
|
{
|
||||||
var patchBundle = BundleList[bundleID];
|
var patchBundle = BundleList[bundleID];
|
||||||
return patchBundle.BundleName;
|
return patchBundle;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -166,17 +166,17 @@ namespace YooAsset
|
|||||||
/// 获取资源依赖列表
|
/// 获取资源依赖列表
|
||||||
/// 注意:传入的资源路径一定合法有效!
|
/// 注意:传入的资源路径一定合法有效!
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string[] GetAllDependencies(string assetPath)
|
public PatchBundle[] GetAllDependencies(string assetPath)
|
||||||
{
|
{
|
||||||
if (Assets.TryGetValue(assetPath, out PatchAsset patchAsset))
|
if (AssetDic.TryGetValue(assetPath, out PatchAsset patchAsset))
|
||||||
{
|
{
|
||||||
List<string> result = new List<string>(patchAsset.DependIDs.Length);
|
List<PatchBundle> result = new List<PatchBundle>(patchAsset.DependIDs.Length);
|
||||||
foreach (var dependID in patchAsset.DependIDs)
|
foreach (var dependID in patchAsset.DependIDs)
|
||||||
{
|
{
|
||||||
if (dependID >= 0 && dependID < BundleList.Count)
|
if (dependID >= 0 && dependID < BundleList.Count)
|
||||||
{
|
{
|
||||||
var dependPatchBundle = BundleList[dependID];
|
var dependPatchBundle = BundleList[dependID];
|
||||||
result.Add(dependPatchBundle.BundleName);
|
result.Add(dependPatchBundle);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -191,6 +191,22 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 尝试获取补丁资源
|
||||||
|
/// </summary>
|
||||||
|
public bool TryGetPatchAsset(string assetPath, out PatchAsset result)
|
||||||
|
{
|
||||||
|
return AssetDic.TryGetValue(assetPath, out result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 尝试获取补丁资源包
|
||||||
|
/// </summary>
|
||||||
|
public bool TryGetPatchBundle(string bundleName, out PatchBundle result)
|
||||||
|
{
|
||||||
|
return BundleDic.TryGetValue(bundleName, out result);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 序列化
|
/// 序列化
|
||||||
@@ -212,7 +228,7 @@ namespace YooAsset
|
|||||||
foreach (var patchBundle in patchManifest.BundleList)
|
foreach (var patchBundle in patchManifest.BundleList)
|
||||||
{
|
{
|
||||||
patchBundle.ParseFlagsValue();
|
patchBundle.ParseFlagsValue();
|
||||||
patchManifest.Bundles.Add(patchBundle.BundleName, patchBundle);
|
patchManifest.BundleDic.Add(patchBundle.BundleName, patchBundle);
|
||||||
}
|
}
|
||||||
|
|
||||||
// AssetList
|
// AssetList
|
||||||
@@ -220,10 +236,10 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
// 注意:我们不允许原始路径存在重名
|
// 注意:我们不允许原始路径存在重名
|
||||||
string assetPath = patchAsset.AssetPath;
|
string assetPath = patchAsset.AssetPath;
|
||||||
if (patchManifest.Assets.ContainsKey(assetPath))
|
if (patchManifest.AssetDic.ContainsKey(assetPath))
|
||||||
throw new Exception($"AssetPath have existed : {assetPath}");
|
throw new Exception($"AssetPath have existed : {assetPath}");
|
||||||
else
|
else
|
||||||
patchManifest.Assets.Add(assetPath, patchAsset);
|
patchManifest.AssetDic.Add(assetPath, patchAsset);
|
||||||
}
|
}
|
||||||
|
|
||||||
return patchManifest;
|
return patchManifest;
|
||||||
|
|||||||
@@ -40,19 +40,13 @@ namespace YooAsset
|
|||||||
#region IBundleServices接口
|
#region IBundleServices接口
|
||||||
BundleInfo IBundleServices.GetBundleInfo(AssetInfo assetInfo)
|
BundleInfo IBundleServices.GetBundleInfo(AssetInfo assetInfo)
|
||||||
{
|
{
|
||||||
if(assetInfo.IsInvalid)
|
if (assetInfo.IsInvalid)
|
||||||
throw new Exception("Should never get here !");
|
throw new Exception("Should never get here !");
|
||||||
|
|
||||||
string bundleName = _simulatePatchManifest.GetBundleName(assetInfo.AssetPath);
|
// 注意:如果补丁清单里未找到资源包会抛出异常!
|
||||||
if (_simulatePatchManifest.Bundles.TryGetValue(bundleName, out PatchBundle patchBundle))
|
var patchBundle = _simulatePatchManifest.GetMainPatchBundle(assetInfo.AssetPath);
|
||||||
{
|
BundleInfo bundleInfo = new BundleInfo(patchBundle, BundleInfo.ELoadMode.LoadFromEditor, assetInfo.AssetPath);
|
||||||
BundleInfo bundleInfo = new BundleInfo(patchBundle, BundleInfo.ELoadMode.LoadFromEditor, assetInfo.AssetPath);
|
return bundleInfo;
|
||||||
return bundleInfo;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new Exception("Should never get here !");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
BundleInfo[] IBundleServices.GetAllDependBundleInfos(AssetInfo assetInfo)
|
BundleInfo[] IBundleServices.GetAllDependBundleInfos(AssetInfo assetInfo)
|
||||||
{
|
{
|
||||||
@@ -64,7 +58,7 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
PatchAsset IBundleServices.TryGetPatchAsset(string assetPath)
|
PatchAsset IBundleServices.TryGetPatchAsset(string assetPath)
|
||||||
{
|
{
|
||||||
if (_simulatePatchManifest.Assets.TryGetValue(assetPath, out PatchAsset patchAsset))
|
if (_simulatePatchManifest.TryGetPatchAsset(assetPath, out PatchAsset patchAsset))
|
||||||
return patchAsset;
|
return patchAsset;
|
||||||
else
|
else
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ namespace YooAsset
|
|||||||
OperationSystem.StartOperaiton(operation);
|
OperationSystem.StartOperaiton(operation);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 异步更新补丁清单(弱联网)
|
/// 异步更新补丁清单(弱联网)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -108,7 +108,7 @@ namespace YooAsset
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(used == false)
|
if (used == false)
|
||||||
{
|
{
|
||||||
YooLogger.Log($"Delete unused cache file : {fileInfo.Name}");
|
YooLogger.Log($"Delete unused cache file : {fileInfo.Name}");
|
||||||
File.Delete(fileInfo.FullName);
|
File.Delete(fileInfo.FullName);
|
||||||
@@ -136,7 +136,7 @@ namespace YooAsset
|
|||||||
|
|
||||||
// 忽略APP资源
|
// 忽略APP资源
|
||||||
// 注意:如果是APP资源并且哈希值相同,则不需要下载
|
// 注意:如果是APP资源并且哈希值相同,则不需要下载
|
||||||
if (AppPatchManifest.Bundles.TryGetValue(patchBundle.BundleName, out PatchBundle appPatchBundle))
|
if (AppPatchManifest.TryGetPatchBundle(patchBundle.BundleName, out PatchBundle appPatchBundle))
|
||||||
{
|
{
|
||||||
if (appPatchBundle.IsBuildin && appPatchBundle.Hash == patchBundle.Hash)
|
if (appPatchBundle.IsBuildin && appPatchBundle.Hash == patchBundle.Hash)
|
||||||
continue;
|
continue;
|
||||||
@@ -168,7 +168,7 @@ namespace YooAsset
|
|||||||
|
|
||||||
// 忽略APP资源
|
// 忽略APP资源
|
||||||
// 注意:如果是APP资源并且哈希值相同,则不需要下载
|
// 注意:如果是APP资源并且哈希值相同,则不需要下载
|
||||||
if (AppPatchManifest.Bundles.TryGetValue(patchBundle.BundleName, out PatchBundle appPatchBundle))
|
if (AppPatchManifest.TryGetPatchBundle(patchBundle.BundleName, out PatchBundle appPatchBundle))
|
||||||
{
|
{
|
||||||
if (appPatchBundle.IsBuildin && appPatchBundle.Hash == patchBundle.Hash)
|
if (appPatchBundle.IsBuildin && appPatchBundle.Hash == patchBundle.Hash)
|
||||||
continue;
|
continue;
|
||||||
@@ -215,21 +215,17 @@ namespace YooAsset
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
string mainBundleName = LocalPatchManifest.GetBundleName(assetInfo.AssetPath);
|
// 注意:如果补丁清单里未找到资源包会抛出异常!
|
||||||
if (LocalPatchManifest.Bundles.TryGetValue(mainBundleName, out PatchBundle mainBundle))
|
PatchBundle mainBundle = LocalPatchManifest.GetMainPatchBundle(assetInfo.AssetPath);
|
||||||
{
|
if (checkList.Contains(mainBundle) == false)
|
||||||
if (checkList.Contains(mainBundle) == false)
|
checkList.Add(mainBundle);
|
||||||
checkList.Add(mainBundle);
|
|
||||||
}
|
|
||||||
|
|
||||||
string[] dependBundleNames = LocalPatchManifest.GetAllDependencies(assetInfo.AssetPath);
|
// 注意:如果补丁清单里未找到资源包会抛出异常!
|
||||||
foreach (var dependBundleName in dependBundleNames)
|
PatchBundle[] dependBundles = LocalPatchManifest.GetAllDependencies(assetInfo.AssetPath);
|
||||||
|
foreach (var dependBundle in dependBundles)
|
||||||
{
|
{
|
||||||
if (LocalPatchManifest.Bundles.TryGetValue(dependBundleName, out PatchBundle dependBundle))
|
if (checkList.Contains(dependBundle) == false)
|
||||||
{
|
checkList.Add(dependBundle);
|
||||||
if (checkList.Contains(dependBundle) == false)
|
|
||||||
checkList.Add(dependBundle);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -242,7 +238,7 @@ namespace YooAsset
|
|||||||
|
|
||||||
// 忽略APP资源
|
// 忽略APP资源
|
||||||
// 注意:如果是APP资源并且哈希值相同,则不需要下载
|
// 注意:如果是APP资源并且哈希值相同,则不需要下载
|
||||||
if (AppPatchManifest.Bundles.TryGetValue(patchBundle.BundleName, out PatchBundle appPatchBundle))
|
if (AppPatchManifest.TryGetPatchBundle(patchBundle.BundleName, out PatchBundle appPatchBundle))
|
||||||
{
|
{
|
||||||
if (appPatchBundle.IsBuildin && appPatchBundle.Hash == patchBundle.Hash)
|
if (appPatchBundle.IsBuildin && appPatchBundle.Hash == patchBundle.Hash)
|
||||||
continue;
|
continue;
|
||||||
@@ -376,53 +372,51 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
|
|
||||||
#region IBundleServices接口
|
#region IBundleServices接口
|
||||||
private BundleInfo CreateBundleInfo(string bundleName)
|
private BundleInfo CreateBundleInfo(PatchBundle patchBundle)
|
||||||
{
|
{
|
||||||
if (LocalPatchManifest.Bundles.TryGetValue(bundleName, out PatchBundle patchBundle))
|
if (patchBundle == null)
|
||||||
|
throw new Exception("Should never get here !");
|
||||||
|
|
||||||
|
// 查询沙盒资源
|
||||||
|
if (DownloadSystem.ContainsVerifyFile(patchBundle.Hash))
|
||||||
{
|
{
|
||||||
// 查询沙盒资源
|
BundleInfo bundleInfo = new BundleInfo(patchBundle, BundleInfo.ELoadMode.LoadFromCache);
|
||||||
if (DownloadSystem.ContainsVerifyFile(patchBundle.Hash))
|
return bundleInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查询APP资源
|
||||||
|
if (AppPatchManifest.TryGetPatchBundle(patchBundle.BundleName, out PatchBundle appPatchBundle))
|
||||||
|
{
|
||||||
|
if (appPatchBundle.IsBuildin && appPatchBundle.Hash == patchBundle.Hash)
|
||||||
{
|
{
|
||||||
BundleInfo bundleInfo = new BundleInfo(patchBundle, BundleInfo.ELoadMode.LoadFromCache);
|
BundleInfo bundleInfo = new BundleInfo(appPatchBundle, BundleInfo.ELoadMode.LoadFromStreaming);
|
||||||
return bundleInfo;
|
return bundleInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 查询APP资源
|
|
||||||
if (AppPatchManifest.Bundles.TryGetValue(bundleName, out PatchBundle appPatchBundle))
|
|
||||||
{
|
|
||||||
if (appPatchBundle.IsBuildin && appPatchBundle.Hash == patchBundle.Hash)
|
|
||||||
{
|
|
||||||
BundleInfo bundleInfo = new BundleInfo(appPatchBundle, BundleInfo.ELoadMode.LoadFromStreaming);
|
|
||||||
return bundleInfo;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 从服务端下载
|
|
||||||
return ConvertToDownloadInfo(patchBundle);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new Exception("Should never get here !");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 从服务端下载
|
||||||
|
return ConvertToDownloadInfo(patchBundle);
|
||||||
}
|
}
|
||||||
BundleInfo IBundleServices.GetBundleInfo(AssetInfo assetInfo)
|
BundleInfo IBundleServices.GetBundleInfo(AssetInfo assetInfo)
|
||||||
{
|
{
|
||||||
if (assetInfo.IsInvalid)
|
if (assetInfo.IsInvalid)
|
||||||
throw new Exception("Should never get here !");
|
throw new Exception("Should never get here !");
|
||||||
|
|
||||||
string bundleName = LocalPatchManifest.GetBundleName(assetInfo.AssetPath);
|
// 注意:如果补丁清单里未找到资源包会抛出异常!
|
||||||
return CreateBundleInfo(bundleName);
|
var patchBundle = LocalPatchManifest.GetMainPatchBundle(assetInfo.AssetPath);
|
||||||
|
return CreateBundleInfo(patchBundle);
|
||||||
}
|
}
|
||||||
BundleInfo[] IBundleServices.GetAllDependBundleInfos(AssetInfo assetInfo)
|
BundleInfo[] IBundleServices.GetAllDependBundleInfos(AssetInfo assetInfo)
|
||||||
{
|
{
|
||||||
if (assetInfo.IsInvalid)
|
if (assetInfo.IsInvalid)
|
||||||
throw new Exception("Should never get here !");
|
throw new Exception("Should never get here !");
|
||||||
|
|
||||||
|
// 注意:如果补丁清单里未找到资源包会抛出异常!
|
||||||
var depends = LocalPatchManifest.GetAllDependencies(assetInfo.AssetPath);
|
var depends = LocalPatchManifest.GetAllDependencies(assetInfo.AssetPath);
|
||||||
List<BundleInfo> result = new List<BundleInfo>(depends.Length);
|
List<BundleInfo> result = new List<BundleInfo>(depends.Length);
|
||||||
foreach (var bundleName in depends)
|
foreach (var patchBundle in depends)
|
||||||
{
|
{
|
||||||
BundleInfo bundleInfo = CreateBundleInfo(bundleName);
|
BundleInfo bundleInfo = CreateBundleInfo(patchBundle);
|
||||||
result.Add(bundleInfo);
|
result.Add(bundleInfo);
|
||||||
}
|
}
|
||||||
return result.ToArray();
|
return result.ToArray();
|
||||||
@@ -433,7 +427,7 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
PatchAsset IBundleServices.TryGetPatchAsset(string assetPath)
|
PatchAsset IBundleServices.TryGetPatchAsset(string assetPath)
|
||||||
{
|
{
|
||||||
if (LocalPatchManifest.Assets.TryGetValue(assetPath, out PatchAsset patchAsset))
|
if (LocalPatchManifest.TryGetPatchAsset(assetPath, out PatchAsset patchAsset))
|
||||||
return patchAsset;
|
return patchAsset;
|
||||||
else
|
else
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -38,36 +38,34 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
|
|
||||||
#region IBundleServices接口
|
#region IBundleServices接口
|
||||||
private BundleInfo CreateBundleInfo(string bundleName)
|
private BundleInfo CreateBundleInfo(PatchBundle patchBundle)
|
||||||
{
|
{
|
||||||
if (_appPatchManifest.Bundles.TryGetValue(bundleName, out PatchBundle patchBundle))
|
if (patchBundle == null)
|
||||||
{
|
|
||||||
BundleInfo bundleInfo = new BundleInfo(patchBundle, BundleInfo.ELoadMode.LoadFromStreaming);
|
|
||||||
return bundleInfo;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new Exception("Should never get here !");
|
throw new Exception("Should never get here !");
|
||||||
}
|
|
||||||
|
BundleInfo bundleInfo = new BundleInfo(patchBundle, BundleInfo.ELoadMode.LoadFromStreaming);
|
||||||
|
return bundleInfo;
|
||||||
}
|
}
|
||||||
BundleInfo IBundleServices.GetBundleInfo(AssetInfo assetInfo)
|
BundleInfo IBundleServices.GetBundleInfo(AssetInfo assetInfo)
|
||||||
{
|
{
|
||||||
if (assetInfo.IsInvalid)
|
if (assetInfo.IsInvalid)
|
||||||
throw new Exception("Should never get here !");
|
throw new Exception("Should never get here !");
|
||||||
|
|
||||||
string bundleName = _appPatchManifest.GetBundleName(assetInfo.AssetPath);
|
// 注意:如果补丁清单里未找到资源包会抛出异常!
|
||||||
return CreateBundleInfo(bundleName);
|
var patchBundle = _appPatchManifest.GetMainPatchBundle(assetInfo.AssetPath);
|
||||||
|
return CreateBundleInfo(patchBundle);
|
||||||
}
|
}
|
||||||
BundleInfo[] IBundleServices.GetAllDependBundleInfos(AssetInfo assetInfo)
|
BundleInfo[] IBundleServices.GetAllDependBundleInfos(AssetInfo assetInfo)
|
||||||
{
|
{
|
||||||
if (assetInfo.IsInvalid)
|
if (assetInfo.IsInvalid)
|
||||||
throw new Exception("Should never get here !");
|
throw new Exception("Should never get here !");
|
||||||
|
|
||||||
|
// 注意:如果补丁清单里未找到资源包会抛出异常!
|
||||||
var depends = _appPatchManifest.GetAllDependencies(assetInfo.AssetPath);
|
var depends = _appPatchManifest.GetAllDependencies(assetInfo.AssetPath);
|
||||||
List<BundleInfo> result = new List<BundleInfo>(depends.Length);
|
List<BundleInfo> result = new List<BundleInfo>(depends.Length);
|
||||||
foreach (var bundleName in depends)
|
foreach (var patchBundle in depends)
|
||||||
{
|
{
|
||||||
BundleInfo bundleInfo = CreateBundleInfo(bundleName);
|
BundleInfo bundleInfo = CreateBundleInfo(patchBundle);
|
||||||
result.Add(bundleInfo);
|
result.Add(bundleInfo);
|
||||||
}
|
}
|
||||||
return result.ToArray();
|
return result.ToArray();
|
||||||
@@ -78,7 +76,7 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
PatchAsset IBundleServices.TryGetPatchAsset(string assetPath)
|
PatchAsset IBundleServices.TryGetPatchAsset(string assetPath)
|
||||||
{
|
{
|
||||||
if (_appPatchManifest.Assets.TryGetValue(assetPath, out PatchAsset patchAsset))
|
if (_appPatchManifest.TryGetPatchAsset(assetPath, out PatchAsset patchAsset))
|
||||||
return patchAsset;
|
return patchAsset;
|
||||||
else
|
else
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -1,11 +1,18 @@
|
|||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
|
public struct DecryptionFileInfo
|
||||||
|
{
|
||||||
|
public string BundleName;
|
||||||
|
public string BundleHash;
|
||||||
|
public string BundleCRC;
|
||||||
|
}
|
||||||
|
|
||||||
public interface IDecryptionServices
|
public interface IDecryptionServices
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取加密文件的数据偏移量
|
/// 获取加密文件的数据偏移量
|
||||||
/// </summary>
|
/// </summary>
|
||||||
ulong GetFileOffset();
|
ulong GetFileOffset(DecryptionFileInfo fileInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -25,6 +25,7 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string UnityManifestFileName = "UnityManifest";
|
public string UnityManifestFileName = "UnityManifest";
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 构建输出的报告文件
|
/// 构建输出的报告文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -34,5 +35,10 @@ namespace YooAsset
|
|||||||
/// 静态版本文件
|
/// 静态版本文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const string VersionFileName = "StaticVersion.bytes";
|
public const string VersionFileName = "StaticVersion.bytes";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Unity内置着色器资源包名称
|
||||||
|
/// </summary>
|
||||||
|
public const string UnityBuiltInShadersBundleName = "UnityBuiltInShaders.bundle";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "com.tuyoogame.yooasset",
|
"name": "com.tuyoogame.yooasset",
|
||||||
"displayName": "YooAsset",
|
"displayName": "YooAsset",
|
||||||
"version": "1.1.1",
|
"version": "1.2.0",
|
||||||
"unity": "2019.4",
|
"unity": "2019.4",
|
||||||
"description": "unity3d resources management system",
|
"description": "unity3d resources management system",
|
||||||
"author": {
|
"author": {
|
||||||
@@ -13,5 +13,10 @@
|
|||||||
"url": "https://github.com/tuyoogame/YooAsset.git"
|
"url": "https://github.com/tuyoogame/YooAsset.git"
|
||||||
},
|
},
|
||||||
"relatedPackages": {},
|
"relatedPackages": {},
|
||||||
"dependencies": {}
|
"dependencies": {
|
||||||
|
"com.unity.scriptablebuildpipeline": "1.20.2",
|
||||||
|
"com.unity.modules.assetbundle": "1.0.0",
|
||||||
|
"com.unity.modules.unitywebrequest": "1.0.0",
|
||||||
|
"com.unity.modules.unitywebrequestassetbundle": "1.0.0"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,14 @@
|
|||||||
|
|
||||||
构建版本号,也是资源版本号,版本号必须大于零。
|
构建版本号,也是资源版本号,版本号必须大于零。
|
||||||
|
|
||||||
|
- **Build Pipeline**
|
||||||
|
|
||||||
|
构建管线
|
||||||
|
|
||||||
|
(1) BuiltinBuildPipeline: 传统的内置构建管线。
|
||||||
|
|
||||||
|
(2) ScriptableBuildPipeline: 可编程构建管线。
|
||||||
|
|
||||||
- **Build Mode**
|
- **Build Mode**
|
||||||
|
|
||||||
构建模式
|
构建模式
|
||||||
|
|||||||
@@ -69,7 +69,13 @@
|
|||||||
|
|
||||||
- MainAssetCollector 收集参与打包的主资源对象,并写入到资源清单的资源列表里(可以通过代码加载)。
|
- MainAssetCollector 收集参与打包的主资源对象,并写入到资源清单的资源列表里(可以通过代码加载)。
|
||||||
- StaticAssetCollector 收集参与打包的主资源对象,但不写入到资源清单的资源列表里(无法通过代码加载)。
|
- StaticAssetCollector 收集参与打包的主资源对象,但不写入到资源清单的资源列表里(无法通过代码加载)。
|
||||||
- DependAssetCollector 收集参与打包的依赖资源对象,但不写入到资源清单的资源列表里(无法通过代码加载)。
|
- DependAssetCollector 收集参与打包的依赖资源对象,但不写入到资源清单的资源列表里(无法通过代码加载)(当依赖资源没有被任何主资源引用的时候,则会在打包的时候自动剔除)。
|
||||||
|
|
||||||
|
StaticAssetCollector收集器和DependAssetCollector收集器适合对资源进行定制化打包策略。
|
||||||
|
|
||||||
|
示例1:一个游戏的粒子特效的纹理会非常多,通常特效制作师会把这些纹理放到一个文件夹内管理。如果我们把这些纹理打进一个AssetBundle文件内,当下次更新的时候,如果新增或改动了一个纹理,那么就要上传整个纹理的AssetBundle文件。我们可以把特效纹理通过DependAssetCollector收集器进行收集并自定义打包规则,通过文件名称的首字母进行小粒度打包,这样一个AssetBundle文件会被拆分为26个AssetBundle文件。
|
||||||
|
|
||||||
|
示例2:当我们需要严格控制某个文件夹内的依赖资源打进同一个AssetBundle文件内,那么StaticAssetCollector收集器是最佳选择,该收集器收集的资源,无论是否被其它资源引用或被多个资源引用,这些资源都会按照设定的打包规则打包,且这些资源不会被处理为share资源包。
|
||||||
|
|
||||||
- **AddressRule**
|
- **AddressRule**
|
||||||
|
|
||||||
|
|||||||
15
Docs/FAQ.md
15
Docs/FAQ.md
@@ -1,13 +1,24 @@
|
|||||||
# 常见问题解答
|
# 常见问题解答
|
||||||
|
|
||||||
### 问题:在编辑器下,用离线模式或联机模式运行游戏,为什么游戏里的模型会变成紫色?
|
#### 问题:在编辑器下,用离线模式或联机模式运行游戏,为什么游戏里的模型会变成紫色?
|
||||||
|
|
||||||
如果在打AssetBundle的时候,选定的构建目标是安卓。那么在windows操作系统下,编辑器的默认渲染模式为DX11,我们需要修改编辑器的渲染模式,可以通过UnityHub来修改启动项目的编辑器渲染模式,[参考官方文档](https://docs.unity3d.com/cn/2019.4/Manual/CommandLineArguments.html)。
|
如果在打AssetBundle的时候,选定的构建目标是安卓。那么在windows操作系统下,编辑器的默认渲染模式为DX11,我们需要修改编辑器的渲染模式,可以通过UnityHub来修改启动项目的编辑器渲染模式,[参考官方文档](https://docs.unity3d.com/cn/2019.4/Manual/CommandLineArguments.html)。
|
||||||
|
|
||||||
### 问题:YooAsset的DLL引用丢失导致编译报错了
|
windows平台添加命令: **-force-gles**
|
||||||
|
|
||||||
|
#### 问题:YooAsset的DLL引用丢失导致编译报错了
|
||||||
|
|
||||||
1. 请在PlayerSetting里修改API Level为.NET 4.x或者.NET Framework
|
1. 请在PlayerSetting里修改API Level为.NET 4.x或者.NET Framework
|
||||||
2. 关闭游戏工程后,删除Assets同级目录下所有的csproj文件和sln文件。
|
2. 关闭游戏工程后,删除Assets同级目录下所有的csproj文件和sln文件。
|
||||||
3. 删除Library/ScriptAssemblies文件夹。
|
3. 删除Library/ScriptAssemblies文件夹。
|
||||||
4. 重新打开游戏工程,然后点击某个脚本重新编译。
|
4. 重新打开游戏工程,然后点击某个脚本重新编译。
|
||||||
|
|
||||||
|
#### 问题:无效的资源路径,请检查路径是否带有特殊符号或中文:Assets/xxx/xxx/xxx
|
||||||
|
|
||||||
|
如果检查报错的文件路径内无特殊符合和中文字符,也可能是文件路径过长且文件名称带空格,在打包生成的manifest文件里文件路径被截断导致验证失败。
|
||||||
|
|
||||||
|
例如:Assets/My Game Res/JMO Assets/Cartoon FX Remaster/CFXR Assets/Shaders/CFXR Particle Glow.shader
|
||||||
|
|
||||||
|
解决方案1:缩短文件路径长度。
|
||||||
|
|
||||||
|
解决方案2:移除文件名称里的空格。
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 39 KiB |
Reference in New Issue
Block a user