mirror of
https://github.com/tuyoogame/YooAsset.git
synced 2026-05-22 16:50:18 +00:00
Compare commits
33 Commits
1.4.3-prev
...
1.4.6-prev
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a0bc521903 | ||
|
|
071a84d9ef | ||
|
|
aa40b5336e | ||
|
|
157402bb39 | ||
|
|
5a98a68c27 | ||
|
|
f6bc52fd59 | ||
|
|
d1f2712e5f | ||
|
|
8958317f61 | ||
|
|
fdf27cbc1a | ||
|
|
26ffb829d0 | ||
|
|
521e3e2587 | ||
|
|
17c6158478 | ||
|
|
fa0dc48993 | ||
|
|
826bdaab5c | ||
|
|
7d21da76fb | ||
|
|
70465a49d7 | ||
|
|
acca74dce7 | ||
|
|
d8e7892ab7 | ||
|
|
e887bf1fd7 | ||
|
|
145ca936e7 | ||
|
|
69c7a51215 | ||
|
|
c4875d4f80 | ||
|
|
eed3c9768b | ||
|
|
2c650f2bdf | ||
|
|
71e8392359 | ||
|
|
cfbf6e23ec | ||
|
|
9be5ec0f31 | ||
|
|
a8a0c3831b | ||
|
|
ef31d5a938 | ||
|
|
812db6dafe | ||
|
|
a64d485278 | ||
|
|
fbba2ddec9 | ||
|
|
6488e96127 |
@@ -2,6 +2,78 @@
|
|||||||
|
|
||||||
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.4.6-preview] - 2023-02-22
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- EVerifyLevel新增Middle级别。
|
||||||
|
|
||||||
|
```c#
|
||||||
|
public enum EVerifyLevel
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 验证文件存在
|
||||||
|
/// </summary>
|
||||||
|
Low,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 验证文件大小
|
||||||
|
/// </summary>
|
||||||
|
Middle,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 验证文件大小和CRC
|
||||||
|
/// </summary>
|
||||||
|
High,
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
- 补丁清单的资源包列表新增引用链。
|
||||||
|
|
||||||
|
(解决复杂依赖关系下,错误卸载资源包的问题)
|
||||||
|
|
||||||
|
- 缓存系统支持后缀格式存储。
|
||||||
|
|
||||||
|
(解决原生文件没有后缀格式的问题)
|
||||||
|
|
||||||
|
- 收集界面增加用户自定义数据栏。
|
||||||
|
|
||||||
|
## [1.4.5-preview] - 2023-02-17
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- (#67)修复了报告查看界面在Unity2021.3上的兼容性问题。
|
||||||
|
- (#66)修复了在Unity2021.3上编辑器模拟模式运行报错的问题。
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- 接口变更:IPackRule
|
||||||
|
|
||||||
|
````c#
|
||||||
|
/// <summary>
|
||||||
|
/// 资源打包规则接口
|
||||||
|
/// </summary>
|
||||||
|
public interface IPackRule
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 获取打包规则结果
|
||||||
|
/// </summary>
|
||||||
|
PackRuleResult GetPackRuleResult(PackRuleData data);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否为原生文件打包规则
|
||||||
|
/// </summary>
|
||||||
|
bool IsRawFilePackRule();
|
||||||
|
}
|
||||||
|
````
|
||||||
|
|
||||||
|
## [1.4.4-preview] - 2023-02-14
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- (#65)修复了AssetBundle构建宏逻辑错误。
|
||||||
|
- 修复了AssetBundle加载宏逻辑错误。
|
||||||
|
|
||||||
## [1.4.3-preview] - 2023-02-10
|
## [1.4.3-preview] - 2023-02-10
|
||||||
|
|
||||||
全新的缓存系统!
|
全新的缓存系统!
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ namespace YooAsset.Editor
|
|||||||
new TaskPrepare(), //前期准备工作
|
new TaskPrepare(), //前期准备工作
|
||||||
new TaskGetBuildMap(), //获取构建列表
|
new TaskGetBuildMap(), //获取构建列表
|
||||||
new TaskBuilding(), //开始执行构建
|
new TaskBuilding(), //开始执行构建
|
||||||
|
new TaskCopyRawFile(), //拷贝原生文件
|
||||||
new TaskVerifyBuildResult(), //验证构建结果
|
new TaskVerifyBuildResult(), //验证构建结果
|
||||||
new TaskEncryption(), //加密资源文件
|
new TaskEncryption(), //加密资源文件
|
||||||
new TaskUpdateBuildInfo(), //更新构建信息
|
new TaskUpdateBuildInfo(), //更新构建信息
|
||||||
@@ -70,6 +71,7 @@ namespace YooAsset.Editor
|
|||||||
new TaskPrepare(), //前期准备工作
|
new TaskPrepare(), //前期准备工作
|
||||||
new TaskGetBuildMap(), //获取构建列表
|
new TaskGetBuildMap(), //获取构建列表
|
||||||
new TaskBuilding_SBP(), //开始执行构建
|
new TaskBuilding_SBP(), //开始执行构建
|
||||||
|
new TaskCopyRawFile(), //拷贝原生文件
|
||||||
new TaskVerifyBuildResult_SBP(), //验证构建结果
|
new TaskVerifyBuildResult_SBP(), //验证构建结果
|
||||||
new TaskEncryption(), //加密资源文件
|
new TaskEncryption(), //加密资源文件
|
||||||
new TaskUpdateBuildInfo(), //更新构建信息
|
new TaskUpdateBuildInfo(), //更新构建信息
|
||||||
|
|||||||
@@ -7,8 +7,6 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
public class BuildAssetInfo
|
public class BuildAssetInfo
|
||||||
{
|
{
|
||||||
private string _mainBundleName;
|
|
||||||
private string _shareBundleName;
|
|
||||||
private bool _isAddAssetTags = false;
|
private bool _isAddAssetTags = false;
|
||||||
private readonly HashSet<string> _referenceBundleNames = new HashSet<string>();
|
private readonly HashSet<string> _referenceBundleNames = new HashSet<string>();
|
||||||
|
|
||||||
@@ -17,6 +15,11 @@ namespace YooAsset.Editor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public ECollectorType CollectorType { private set; get; }
|
public ECollectorType CollectorType { private set; get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 资源包完整名称
|
||||||
|
/// </summary>
|
||||||
|
public string BundleName { private set; get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 可寻址地址
|
/// 可寻址地址
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -54,10 +57,10 @@ namespace YooAsset.Editor
|
|||||||
public List<BuildAssetInfo> AllDependAssetInfos { private set; get; }
|
public List<BuildAssetInfo> AllDependAssetInfos { private set; get; }
|
||||||
|
|
||||||
|
|
||||||
public BuildAssetInfo(ECollectorType collectorType, string mainBundleName, string address, string assetPath, bool isRawAsset)
|
public BuildAssetInfo(ECollectorType collectorType, string bundleName, string address, string assetPath, bool isRawAsset)
|
||||||
{
|
{
|
||||||
_mainBundleName = mainBundleName;
|
|
||||||
CollectorType = collectorType;
|
CollectorType = collectorType;
|
||||||
|
BundleName = bundleName;
|
||||||
Address = address;
|
Address = address;
|
||||||
AssetPath = assetPath;
|
AssetPath = assetPath;
|
||||||
IsRawAsset = isRawAsset;
|
IsRawAsset = isRawAsset;
|
||||||
@@ -133,24 +136,12 @@ namespace YooAsset.Editor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public bool HasBundleName()
|
public bool HasBundleName()
|
||||||
{
|
{
|
||||||
string bundleName = GetBundleName();
|
if (string.IsNullOrEmpty(BundleName))
|
||||||
if (string.IsNullOrEmpty(bundleName))
|
|
||||||
return false;
|
return false;
|
||||||
else
|
else
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 获取资源包名称
|
|
||||||
/// </summary>
|
|
||||||
public string GetBundleName()
|
|
||||||
{
|
|
||||||
if (CollectorType == ECollectorType.None)
|
|
||||||
return _shareBundleName;
|
|
||||||
else
|
|
||||||
return _mainBundleName;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 添加关联的资源包名称
|
/// 添加关联的资源包名称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -164,53 +155,32 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 计算主资源或共享资源的完整包名
|
/// 计算共享资源包的完整包名
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void CalculateFullBundleName(bool uniqueBundleName, string packageName)
|
public void CalculateShareBundleName(bool uniqueBundleName, string packageName, string shadersBundleName)
|
||||||
{
|
{
|
||||||
if (CollectorType == ECollectorType.None)
|
if (CollectorType != ECollectorType.None)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (IsRawAsset)
|
||||||
|
throw new Exception("Should never get here !");
|
||||||
|
|
||||||
|
if (IsShaderAsset)
|
||||||
{
|
{
|
||||||
if (IsRawAsset)
|
BundleName = shadersBundleName;
|
||||||
throw new Exception("Should never get here !");
|
|
||||||
|
|
||||||
if (IsShaderAsset)
|
|
||||||
{
|
|
||||||
_shareBundleName = YooAssetSettingsData.GetUnityShadersBundleFullName(uniqueBundleName, packageName);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (_referenceBundleNames.Count > 1)
|
|
||||||
{
|
|
||||||
IPackRule packRule = PackDirectory.StaticPackRule;
|
|
||||||
var bundleName = packRule.GetBundleName(new PackRuleData(AssetPath));
|
|
||||||
if (YooAssetSettingsData.Setting.RegularBundleName)
|
|
||||||
bundleName = EditorTools.GetRegularPath(bundleName).Replace('/', '_').Replace('.', '_').ToLower();
|
|
||||||
else
|
|
||||||
bundleName = EditorTools.GetRegularPath(bundleName).ToLower();
|
|
||||||
|
|
||||||
if (uniqueBundleName)
|
|
||||||
_shareBundleName = $"{packageName.ToLower()}_share_{bundleName}.{YooAssetSettingsData.Setting.AssetBundleFileVariant}";
|
|
||||||
else
|
|
||||||
_shareBundleName = $"share_{bundleName}.{YooAssetSettingsData.Setting.AssetBundleFileVariant}";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (IsRawAsset)
|
if (_referenceBundleNames.Count > 1)
|
||||||
{
|
{
|
||||||
string mainBundleName = $"{_mainBundleName}.{YooAssetSettingsData.Setting.RawBundleFileVariant}";
|
IPackRule packRule = PackDirectory.StaticPackRule;
|
||||||
_mainBundleName = mainBundleName.ToLower();
|
PackRuleResult packRuleResult = packRule.GetPackRuleResult(new PackRuleData(AssetPath));
|
||||||
|
BundleName = packRuleResult.GetShareBundleName(packageName, uniqueBundleName);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
string mainBundleName = $"{_mainBundleName}.{YooAssetSettingsData.Setting.AssetBundleFileVariant}";
|
// 注意:被引用次数小于1的资源不需要设置资源包名称
|
||||||
_mainBundleName = mainBundleName.ToLower(); ;
|
BundleName = string.Empty;
|
||||||
}
|
|
||||||
|
|
||||||
if (uniqueBundleName)
|
|
||||||
{
|
|
||||||
_mainBundleName = $"{packageName.ToLower()}_{_mainBundleName}";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,11 @@ namespace YooAsset.Editor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public bool UniqueBundleName;
|
public bool UniqueBundleName;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 着色器统一的全名称
|
||||||
|
/// </summary>
|
||||||
|
public string ShadersBundleName;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源包列表
|
/// 资源包列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -35,7 +40,7 @@ namespace YooAsset.Editor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void PackAsset(BuildAssetInfo assetInfo)
|
public void PackAsset(BuildAssetInfo assetInfo)
|
||||||
{
|
{
|
||||||
string bundleName = assetInfo.GetBundleName();
|
string bundleName = assetInfo.BundleName;
|
||||||
if (string.IsNullOrEmpty(bundleName))
|
if (string.IsNullOrEmpty(bundleName))
|
||||||
throw new Exception("Should never get here !");
|
throw new Exception("Should never get here !");
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ namespace YooAsset.Editor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static BuildMapContext CreateBuildMap(EBuildMode buildMode, string packageName)
|
public static BuildMapContext CreateBuildMap(EBuildMode buildMode, string packageName)
|
||||||
{
|
{
|
||||||
BuildMapContext context = new BuildMapContext();
|
|
||||||
Dictionary<string, BuildAssetInfo> buildAssetDic = new Dictionary<string, BuildAssetInfo>(1000);
|
Dictionary<string, BuildAssetInfo> buildAssetDic = new Dictionary<string, BuildAssetInfo>(1000);
|
||||||
|
|
||||||
// 1. 检测配置合法性
|
// 1. 检测配置合法性
|
||||||
@@ -22,7 +21,7 @@ namespace YooAsset.Editor
|
|||||||
var buildResult = AssetBundleCollectorSettingData.Setting.GetPackageAssets(buildMode, packageName);
|
var buildResult = AssetBundleCollectorSettingData.Setting.GetPackageAssets(buildMode, packageName);
|
||||||
List<CollectAssetInfo> allCollectAssets = buildResult.CollectAssets;
|
List<CollectAssetInfo> allCollectAssets = buildResult.CollectAssets;
|
||||||
|
|
||||||
// 3. 剔除未被引用的依赖资源
|
// 3. 剔除未被引用的依赖项资源
|
||||||
List<CollectAssetInfo> removeDependList = new List<CollectAssetInfo>();
|
List<CollectAssetInfo> removeDependList = new List<CollectAssetInfo>();
|
||||||
foreach (var collectAssetInfo in allCollectAssets)
|
foreach (var collectAssetInfo in allCollectAssets)
|
||||||
{
|
{
|
||||||
@@ -42,7 +41,8 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
if (buildAssetDic.ContainsKey(collectAssetInfo.AssetPath) == false)
|
if (buildAssetDic.ContainsKey(collectAssetInfo.AssetPath) == false)
|
||||||
{
|
{
|
||||||
var buildAssetInfo = new BuildAssetInfo(collectAssetInfo.CollectorType, collectAssetInfo.BundleName,
|
var buildAssetInfo = new BuildAssetInfo(
|
||||||
|
collectAssetInfo.CollectorType, collectAssetInfo.BundleName,
|
||||||
collectAssetInfo.Address, collectAssetInfo.AssetPath, collectAssetInfo.IsRawAsset);
|
collectAssetInfo.Address, collectAssetInfo.AssetPath, collectAssetInfo.IsRawAsset);
|
||||||
buildAssetInfo.AddAssetTags(collectAssetInfo.AssetTags);
|
buildAssetInfo.AddAssetTags(collectAssetInfo.AssetTags);
|
||||||
buildAssetInfo.AddBundleTags(collectAssetInfo.AssetTags);
|
buildAssetInfo.AddBundleTags(collectAssetInfo.AssetTags);
|
||||||
@@ -54,32 +54,28 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 5. 录入相关依赖的资源
|
// 5. 录入所有收集资源的依赖资源
|
||||||
foreach (var collectAssetInfo in allCollectAssets)
|
foreach (var collectAssetInfo in allCollectAssets)
|
||||||
{
|
{
|
||||||
|
string collectAssetBundleName = collectAssetInfo.BundleName;
|
||||||
foreach (var dependAssetPath in collectAssetInfo.DependAssets)
|
foreach (var dependAssetPath in collectAssetInfo.DependAssets)
|
||||||
{
|
{
|
||||||
if (buildAssetDic.ContainsKey(dependAssetPath))
|
if (buildAssetDic.ContainsKey(dependAssetPath))
|
||||||
{
|
{
|
||||||
buildAssetDic[dependAssetPath].AddBundleTags(collectAssetInfo.AssetTags);
|
buildAssetDic[dependAssetPath].AddBundleTags(collectAssetInfo.AssetTags);
|
||||||
buildAssetDic[dependAssetPath].AddReferenceBundleName(collectAssetInfo.BundleName);
|
buildAssetDic[dependAssetPath].AddReferenceBundleName(collectAssetBundleName);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var buildAssetInfo = new BuildAssetInfo(dependAssetPath);
|
var buildAssetInfo = new BuildAssetInfo(dependAssetPath);
|
||||||
buildAssetInfo.AddBundleTags(collectAssetInfo.AssetTags);
|
buildAssetInfo.AddBundleTags(collectAssetInfo.AssetTags);
|
||||||
buildAssetInfo.AddReferenceBundleName(collectAssetInfo.BundleName);
|
buildAssetInfo.AddReferenceBundleName(collectAssetBundleName);
|
||||||
buildAssetDic.Add(dependAssetPath, buildAssetInfo);
|
buildAssetDic.Add(dependAssetPath, buildAssetInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 6. 记录关键信息
|
// 6. 填充所有收集资源的依赖列表
|
||||||
context.AssetFileCount = buildAssetDic.Count;
|
|
||||||
context.EnableAddressable = buildResult.EnableAddressable;
|
|
||||||
context.UniqueBundleName = buildResult.UniqueBundleName;
|
|
||||||
|
|
||||||
// 7. 填充主动收集资源的依赖列表
|
|
||||||
foreach (var collectAssetInfo in allCollectAssets)
|
foreach (var collectAssetInfo in allCollectAssets)
|
||||||
{
|
{
|
||||||
var dependAssetInfos = new List<BuildAssetInfo>(collectAssetInfo.DependAssets.Count);
|
var dependAssetInfos = new List<BuildAssetInfo>(collectAssetInfo.DependAssets.Count);
|
||||||
@@ -93,10 +89,18 @@ namespace YooAsset.Editor
|
|||||||
buildAssetDic[collectAssetInfo.AssetPath].SetAllDependAssetInfos(dependAssetInfos);
|
buildAssetDic[collectAssetInfo.AssetPath].SetAllDependAssetInfos(dependAssetInfos);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 8. 计算完整的资源包名
|
// 7. 记录关键信息
|
||||||
|
BuildMapContext context = new BuildMapContext();
|
||||||
|
context.AssetFileCount = buildAssetDic.Count;
|
||||||
|
context.EnableAddressable = buildResult.Command.EnableAddressable;
|
||||||
|
context.UniqueBundleName = buildResult.Command.UniqueBundleName;
|
||||||
|
context.ShadersBundleName = buildResult.ShadersBundleName;
|
||||||
|
|
||||||
|
// 8. 计算共享的资源包名
|
||||||
|
var command = buildResult.Command;
|
||||||
foreach (KeyValuePair<string, BuildAssetInfo> pair in buildAssetDic)
|
foreach (KeyValuePair<string, BuildAssetInfo> pair in buildAssetDic)
|
||||||
{
|
{
|
||||||
pair.Value.CalculateFullBundleName(buildResult.UniqueBundleName, buildResult.PackageName);
|
pair.Value.CalculateShareBundleName(command.UniqueBundleName, command.PackageName, buildResult.ShadersBundleName);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 9. 移除不参与构建的资源
|
// 9. 移除不参与构建的资源
|
||||||
|
|||||||
@@ -45,32 +45,6 @@ namespace YooAsset.Editor
|
|||||||
BuildResultContext buildResultContext = new BuildResultContext();
|
BuildResultContext buildResultContext = new BuildResultContext();
|
||||||
buildResultContext.UnityManifest = buildResults;
|
buildResultContext.UnityManifest = buildResults;
|
||||||
context.SetContextObject(buildResultContext);
|
context.SetContextObject(buildResultContext);
|
||||||
|
|
||||||
// 拷贝原生文件
|
|
||||||
if (buildMode == EBuildMode.ForceRebuild || buildMode == EBuildMode.IncrementalBuild)
|
|
||||||
{
|
|
||||||
CopyRawBundle(buildMapContext, buildParametersContext);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 拷贝原生文件
|
|
||||||
/// </summary>
|
|
||||||
private void CopyRawBundle(BuildMapContext buildMapContext, BuildParametersContext buildParametersContext)
|
|
||||||
{
|
|
||||||
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
|
|
||||||
foreach (var bundleInfo in buildMapContext.BundleInfos)
|
|
||||||
{
|
|
||||||
if (bundleInfo.IsRawFile)
|
|
||||||
{
|
|
||||||
string dest = $"{pipelineOutputDirectory}/{bundleInfo.BundleName}";
|
|
||||||
foreach (var buildAsset in bundleInfo.BuildinAssets)
|
|
||||||
{
|
|
||||||
if (buildAsset.IsRawAsset)
|
|
||||||
EditorTools.CopyFile(buildAsset.AssetPath, dest, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -33,8 +33,7 @@ namespace YooAsset.Editor
|
|||||||
// 开始构建
|
// 开始构建
|
||||||
IBundleBuildResults buildResults;
|
IBundleBuildResults buildResults;
|
||||||
var buildParameters = buildParametersContext.GetSBPBuildParameters();
|
var buildParameters = buildParametersContext.GetSBPBuildParameters();
|
||||||
var shadersBunldeName = YooAssetSettingsData.GetUnityShadersBundleFullName(buildMapContext.UniqueBundleName, buildParametersContext.Parameters.PackageName);
|
var taskList = SBPBuildTasks.Create(buildMapContext.ShadersBundleName);
|
||||||
var taskList = SBPBuildTasks.Create(shadersBunldeName);
|
|
||||||
ReturnCode exitCode = ContentPipeline.BuildAssetBundles(buildParameters, buildContent, out buildResults, taskList);
|
ReturnCode exitCode = ContentPipeline.BuildAssetBundles(buildParameters, buildContent, out buildResults, taskList);
|
||||||
if (exitCode < 0)
|
if (exitCode < 0)
|
||||||
{
|
{
|
||||||
@@ -45,32 +44,6 @@ namespace YooAsset.Editor
|
|||||||
BuildResultContext buildResultContext = new BuildResultContext();
|
BuildResultContext buildResultContext = new BuildResultContext();
|
||||||
buildResultContext.Results = buildResults;
|
buildResultContext.Results = buildResults;
|
||||||
context.SetContextObject(buildResultContext);
|
context.SetContextObject(buildResultContext);
|
||||||
|
|
||||||
// 拷贝原生文件
|
|
||||||
if (buildMode == EBuildMode.ForceRebuild || buildMode == EBuildMode.IncrementalBuild)
|
|
||||||
{
|
|
||||||
CopyRawBundle(buildMapContext, buildParametersContext);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 拷贝原生文件
|
|
||||||
/// </summary>
|
|
||||||
private void CopyRawBundle(BuildMapContext buildMapContext, BuildParametersContext buildParametersContext)
|
|
||||||
{
|
|
||||||
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
|
|
||||||
foreach (var bundleInfo in buildMapContext.BundleInfos)
|
|
||||||
{
|
|
||||||
if (bundleInfo.IsRawFile)
|
|
||||||
{
|
|
||||||
string dest = $"{pipelineOutputDirectory}/{bundleInfo.BundleName}";
|
|
||||||
foreach (var buildAsset in bundleInfo.BuildinAssets)
|
|
||||||
{
|
|
||||||
if (buildAsset.IsRawAsset)
|
|
||||||
EditorTools.CopyFile(buildAsset.AssetPath, dest, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
[TaskAttribute("拷贝原生文件")]
|
||||||
|
public class TaskCopyRawFile : IBuildTask
|
||||||
|
{
|
||||||
|
void IBuildTask.Run(BuildContext context)
|
||||||
|
{
|
||||||
|
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||||
|
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
||||||
|
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||||
|
|
||||||
|
var buildMode = buildParameters.Parameters.BuildMode;
|
||||||
|
if (buildMode == EBuildMode.ForceRebuild || buildMode == EBuildMode.IncrementalBuild)
|
||||||
|
{
|
||||||
|
CopyRawBundle(buildMapContext, buildParametersContext);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 拷贝原生文件
|
||||||
|
/// </summary>
|
||||||
|
private void CopyRawBundle(BuildMapContext buildMapContext, BuildParametersContext buildParametersContext)
|
||||||
|
{
|
||||||
|
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
|
||||||
|
foreach (var bundleInfo in buildMapContext.BundleInfos)
|
||||||
|
{
|
||||||
|
if (bundleInfo.IsRawFile)
|
||||||
|
{
|
||||||
|
string dest = $"{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: 3625d4b8b5b79324ebf7ec19a87677e7
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -42,13 +42,32 @@ namespace YooAsset.Editor
|
|||||||
patchManifest.AssetList = GetAllPatchAsset(context, patchManifest);
|
patchManifest.AssetList = GetAllPatchAsset(context, patchManifest);
|
||||||
|
|
||||||
// 更新Unity内置资源包的引用关系
|
// 更新Unity内置资源包的引用关系
|
||||||
string shadersBunldeName = YooAssetSettingsData.GetUnityShadersBundleFullName(buildMapContext.UniqueBundleName, buildParameters.PackageName);
|
|
||||||
if (buildParameters.BuildPipeline == EBuildPipeline.ScriptableBuildPipeline)
|
if (buildParameters.BuildPipeline == EBuildPipeline.ScriptableBuildPipeline)
|
||||||
{
|
{
|
||||||
if (buildParameters.BuildMode == EBuildMode.IncrementalBuild)
|
if (buildParameters.BuildMode == EBuildMode.IncrementalBuild)
|
||||||
{
|
{
|
||||||
var buildResultContext = context.GetContextObject<TaskBuilding_SBP.BuildResultContext>();
|
var buildResultContext = context.GetContextObject<TaskBuilding_SBP.BuildResultContext>();
|
||||||
UpdateBuiltInBundleReference(patchManifest, buildResultContext.Results, shadersBunldeName);
|
UpdateBuiltInBundleReference(patchManifest, buildResultContext, buildMapContext.ShadersBundleName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 更新资源包之间的引用关系
|
||||||
|
if (buildParameters.BuildPipeline == EBuildPipeline.ScriptableBuildPipeline)
|
||||||
|
{
|
||||||
|
if (buildParameters.BuildMode == EBuildMode.IncrementalBuild)
|
||||||
|
{
|
||||||
|
var buildResultContext = context.GetContextObject<TaskBuilding_SBP.BuildResultContext>();
|
||||||
|
UpdateScriptPipelineReference(patchManifest, buildResultContext);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 更新资源包之间的引用关系
|
||||||
|
if (buildParameters.BuildPipeline == EBuildPipeline.BuiltinBuildPipeline)
|
||||||
|
{
|
||||||
|
if (buildParameters.BuildMode != EBuildMode.SimulateBuild)
|
||||||
|
{
|
||||||
|
var buildResultContext = context.GetContextObject<TaskBuilding.BuildResultContext>();
|
||||||
|
UpdateBuiltinPipelineReference(patchManifest, buildResultContext, buildMapContext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -98,7 +117,6 @@ namespace YooAsset.Editor
|
|||||||
private List<PatchBundle> GetAllPatchBundle(BuildContext context)
|
private List<PatchBundle> GetAllPatchBundle(BuildContext context)
|
||||||
{
|
{
|
||||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
|
||||||
|
|
||||||
List<PatchBundle> result = new List<PatchBundle>(1000);
|
List<PatchBundle> result = new List<PatchBundle>(1000);
|
||||||
foreach (var bundleInfo in buildMapContext.BundleInfos)
|
foreach (var bundleInfo in buildMapContext.BundleInfos)
|
||||||
@@ -129,7 +147,7 @@ namespace YooAsset.Editor
|
|||||||
patchAsset.Address = string.Empty;
|
patchAsset.Address = string.Empty;
|
||||||
patchAsset.AssetPath = assetInfo.AssetPath;
|
patchAsset.AssetPath = assetInfo.AssetPath;
|
||||||
patchAsset.AssetTags = assetInfo.AssetTags.ToArray();
|
patchAsset.AssetTags = assetInfo.AssetTags.ToArray();
|
||||||
patchAsset.BundleID = GetAssetBundleID(assetInfo.GetBundleName(), patchManifest);
|
patchAsset.BundleID = GetAssetBundleID(assetInfo.BundleName, patchManifest);
|
||||||
patchAsset.DependIDs = GetAssetBundleDependIDs(patchAsset.BundleID, assetInfo, patchManifest);
|
patchAsset.DependIDs = GetAssetBundleDependIDs(patchAsset.BundleID, assetInfo, patchManifest);
|
||||||
result.Add(patchAsset);
|
result.Add(patchAsset);
|
||||||
}
|
}
|
||||||
@@ -143,7 +161,7 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
if (dependAssetInfo.HasBundleName())
|
if (dependAssetInfo.HasBundleName())
|
||||||
{
|
{
|
||||||
int bundleID = GetAssetBundleID(dependAssetInfo.GetBundleName(), patchManifest);
|
int bundleID = GetAssetBundleID(dependAssetInfo.BundleName, patchManifest);
|
||||||
if (mainBundleID != bundleID)
|
if (mainBundleID != bundleID)
|
||||||
{
|
{
|
||||||
if (result.Contains(bundleID) == false)
|
if (result.Contains(bundleID) == false)
|
||||||
@@ -166,11 +184,11 @@ namespace YooAsset.Editor
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 更新Unity内置资源包的引用关系
|
/// 更新Unity内置资源包的引用关系
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void UpdateBuiltInBundleReference(PatchManifest patchManifest, IBundleBuildResults buildResults, string shadersBunldeName)
|
private void UpdateBuiltInBundleReference(PatchManifest patchManifest, TaskBuilding_SBP.BuildResultContext buildResultContext, string shadersBunldeName)
|
||||||
{
|
{
|
||||||
// 获取所有依赖着色器资源包的资源包列表
|
// 获取所有依赖着色器资源包的资源包列表
|
||||||
List<string> shaderBundleReferenceList = new List<string>();
|
List<string> shaderBundleReferenceList = new List<string>();
|
||||||
foreach (var valuePair in buildResults.BundleInfos)
|
foreach (var valuePair in buildResultContext.Results.BundleInfos)
|
||||||
{
|
{
|
||||||
if (valuePair.Value.Dependencies.Any(t => t == shadersBunldeName))
|
if (valuePair.Value.Dependencies.Any(t => t == shadersBunldeName))
|
||||||
shaderBundleReferenceList.Add(valuePair.Key);
|
shaderBundleReferenceList.Add(valuePair.Key);
|
||||||
@@ -212,5 +230,79 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 更新资源包之间的引用关系
|
||||||
|
/// </summary>
|
||||||
|
private void UpdateScriptPipelineReference(PatchManifest patchManifest, TaskBuilding_SBP.BuildResultContext buildResultContext)
|
||||||
|
{
|
||||||
|
foreach (var patchBundle in patchManifest.BundleList)
|
||||||
|
{
|
||||||
|
patchBundle.ReferenceIDs = GetScriptPipelineRefrenceIDs(patchManifest, patchBundle, buildResultContext);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private int[] GetScriptPipelineRefrenceIDs(PatchManifest patchManifest, PatchBundle patchBundle, TaskBuilding_SBP.BuildResultContext buildResultContext)
|
||||||
|
{
|
||||||
|
if (buildResultContext.Results.BundleInfos.TryGetValue(patchBundle.BundleName, out var details) == false)
|
||||||
|
{
|
||||||
|
throw new Exception("Should never get here !");
|
||||||
|
}
|
||||||
|
|
||||||
|
List<string> referenceList = new List<string>();
|
||||||
|
foreach (var keyValuePair in buildResultContext.Results.BundleInfos)
|
||||||
|
{
|
||||||
|
string bundleName = keyValuePair.Key;
|
||||||
|
if (bundleName == patchBundle.BundleName)
|
||||||
|
continue;
|
||||||
|
if (keyValuePair.Value.Dependencies.Contains(patchBundle.BundleName))
|
||||||
|
{
|
||||||
|
referenceList.Add(bundleName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
List<int> result = new List<int>();
|
||||||
|
foreach (var bundleName in referenceList)
|
||||||
|
{
|
||||||
|
int bundleID = GetAssetBundleID(bundleName, patchManifest);
|
||||||
|
if (result.Contains(bundleID) == false)
|
||||||
|
result.Add(bundleID);
|
||||||
|
}
|
||||||
|
return result.ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 更新资源包之间的引用关系
|
||||||
|
/// </summary>
|
||||||
|
private void UpdateBuiltinPipelineReference(PatchManifest patchManifest, TaskBuilding.BuildResultContext buildResultContext, BuildMapContext buildMapContext)
|
||||||
|
{
|
||||||
|
foreach (var patchBundle in patchManifest.BundleList)
|
||||||
|
{
|
||||||
|
patchBundle.ReferenceIDs = GetBuiltinPipelineRefrenceIDs(patchManifest, patchBundle, buildResultContext, buildMapContext);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private int[] GetBuiltinPipelineRefrenceIDs(PatchManifest patchManifest, PatchBundle patchBundle, TaskBuilding.BuildResultContext buildResultContext, BuildMapContext buildMapContext)
|
||||||
|
{
|
||||||
|
List<string> referenceList = new List<string>();
|
||||||
|
foreach (var bundleInfo in buildMapContext.BundleInfos)
|
||||||
|
{
|
||||||
|
string bundleName = bundleInfo.BundleName;
|
||||||
|
if (bundleName == patchBundle.BundleName)
|
||||||
|
continue;
|
||||||
|
string[] dependencies = buildResultContext.UnityManifest.GetAllDependencies(bundleName);
|
||||||
|
if (dependencies.Contains(patchBundle.BundleName))
|
||||||
|
{
|
||||||
|
referenceList.Add(bundleName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
List<int> result = new List<int>();
|
||||||
|
foreach (var bundleName in referenceList)
|
||||||
|
{
|
||||||
|
int bundleID = GetAssetBundleID(bundleName, patchManifest);
|
||||||
|
if (result.Contains(bundleID) == false)
|
||||||
|
result.Add(bundleID);
|
||||||
|
}
|
||||||
|
return result.ToArray();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -16,11 +16,6 @@ namespace YooAsset.Editor
|
|||||||
|
|
||||||
var buildParameters = buildParametersContext.Parameters;
|
var buildParameters = buildParametersContext.Parameters;
|
||||||
|
|
||||||
#if !UNITY_2021_1_OR_NEWER
|
|
||||||
if (buildParameters.BuildPipeline == EBuildPipeline.BuiltinBuildPipeline)
|
|
||||||
throw new Exception($"Unity2021 or newer not support {nameof(EBuildPipeline.BuiltinBuildPipeline)}, Please use {nameof(EBuildPipeline.ScriptableBuildPipeline)}");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// 检测构建参数合法性
|
// 检测构建参数合法性
|
||||||
if (buildParameters.BuildTarget == BuildTarget.NoTarget)
|
if (buildParameters.BuildTarget == BuildTarget.NoTarget)
|
||||||
throw new Exception("请选择目标平台");
|
throw new Exception("请选择目标平台");
|
||||||
|
|||||||
@@ -48,7 +48,8 @@ namespace YooAsset.Editor
|
|||||||
// 4.更新补丁包输出的文件路径
|
// 4.更新补丁包输出的文件路径
|
||||||
foreach (var bundleInfo in buildMapContext.BundleInfos)
|
foreach (var bundleInfo in buildMapContext.BundleInfos)
|
||||||
{
|
{
|
||||||
string patchFileName = PatchManifestTools.CreateBundleFileName(outputNameStyle, bundleInfo.BundleName, bundleInfo.PatchInfo.PatchFileHash, bundleInfo.IsRawFile);
|
string patchFileExtension = PatchManifestTools.GetRemoteBundleFileExtension(bundleInfo.BundleName);
|
||||||
|
string patchFileName = PatchManifestTools.GetRemoteBundleFileName(outputNameStyle, bundleInfo.BundleName, patchFileExtension, bundleInfo.PatchInfo.PatchFileHash);
|
||||||
bundleInfo.PatchInfo.PatchOutputFilePath = $"{packageOutputDirectory}/{patchFileName}";
|
bundleInfo.PatchInfo.PatchOutputFilePath = $"{packageOutputDirectory}/{patchFileName}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,6 +45,11 @@ namespace YooAsset.Editor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string AssetTags = string.Empty;
|
public string AssetTags = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 用户自定义数据
|
||||||
|
/// </summary>
|
||||||
|
public string UserData = string.Empty;
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 收集器是否有效
|
/// 收集器是否有效
|
||||||
@@ -142,11 +147,14 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
|
|
||||||
Dictionary<string, CollectAssetInfo> result = new Dictionary<string, CollectAssetInfo>(1000);
|
Dictionary<string, CollectAssetInfo> result = new Dictionary<string, CollectAssetInfo>(1000);
|
||||||
bool isRawAsset = PackRuleName == nameof(PackRawFile);
|
|
||||||
|
// 检测是否为原生资源打包规则
|
||||||
|
IPackRule packRuleInstance = AssetBundleCollectorSettingData.GetPackRuleInstance(PackRuleName);
|
||||||
|
bool isRawFilePackRule = packRuleInstance.IsRawFilePackRule();
|
||||||
|
|
||||||
// 检测原生资源包的收集器类型
|
// 检测原生资源包的收集器类型
|
||||||
if (isRawAsset && CollectorType != ECollectorType.MainAssetCollector)
|
if (isRawFilePackRule && CollectorType != ECollectorType.MainAssetCollector)
|
||||||
throw new Exception($"The raw file must be set to {nameof(ECollectorType)}.{ECollectorType.MainAssetCollector} : {CollectPath}");
|
throw new Exception($"The raw file pack rule must be set to {nameof(ECollectorType)}.{ECollectorType.MainAssetCollector} : {CollectPath}");
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(CollectPath))
|
if (string.IsNullOrEmpty(CollectPath))
|
||||||
throw new Exception($"The collect path is null or empty in group : {group.GroupName}");
|
throw new Exception($"The collect path is null or empty in group : {group.GroupName}");
|
||||||
@@ -158,11 +166,11 @@ namespace YooAsset.Editor
|
|||||||
string[] findAssets = EditorTools.FindAssets(EAssetSearchType.All, collectDirectory);
|
string[] findAssets = EditorTools.FindAssets(EAssetSearchType.All, collectDirectory);
|
||||||
foreach (string assetPath in findAssets)
|
foreach (string assetPath in findAssets)
|
||||||
{
|
{
|
||||||
if (IsValidateAsset(assetPath) && IsCollectAsset(assetPath))
|
if (IsValidateAsset(assetPath, isRawFilePackRule) && IsCollectAsset(assetPath))
|
||||||
{
|
{
|
||||||
if (result.ContainsKey(assetPath) == false)
|
if (result.ContainsKey(assetPath) == false)
|
||||||
{
|
{
|
||||||
var collectAssetInfo = CreateCollectAssetInfo(command, group, assetPath, isRawAsset);
|
var collectAssetInfo = CreateCollectAssetInfo(command, group, assetPath, isRawFilePackRule);
|
||||||
result.Add(assetPath, collectAssetInfo);
|
result.Add(assetPath, collectAssetInfo);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -175,9 +183,9 @@ namespace YooAsset.Editor
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
string assetPath = CollectPath;
|
string assetPath = CollectPath;
|
||||||
if (IsValidateAsset(assetPath) && IsCollectAsset(assetPath))
|
if (IsValidateAsset(assetPath, isRawFilePackRule) && IsCollectAsset(assetPath))
|
||||||
{
|
{
|
||||||
var collectAssetInfo = CreateCollectAssetInfo(command, group, assetPath, isRawAsset);
|
var collectAssetInfo = CreateCollectAssetInfo(command, group, assetPath, isRawFilePackRule);
|
||||||
result.Add(assetPath, collectAssetInfo);
|
result.Add(assetPath, collectAssetInfo);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -207,22 +215,22 @@ namespace YooAsset.Editor
|
|||||||
return result.Values.ToList();
|
return result.Values.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
private CollectAssetInfo CreateCollectAssetInfo(CollectCommand command, AssetBundleCollectorGroup group, string assetPath, bool isRawAsset)
|
private CollectAssetInfo CreateCollectAssetInfo(CollectCommand command, AssetBundleCollectorGroup group, string assetPath, bool isRawFilePackRule)
|
||||||
{
|
{
|
||||||
string address = GetAddress(group, assetPath);
|
string address = GetAddress(group, assetPath);
|
||||||
string bundleName = GetBundleName(group, assetPath);
|
string bundleName = GetBundleName(command, group, assetPath);
|
||||||
List<string> assetTags = GetAssetTags(group);
|
List<string> assetTags = GetAssetTags(group);
|
||||||
CollectAssetInfo collectAssetInfo = new CollectAssetInfo(CollectorType, bundleName, address, assetPath, assetTags, isRawAsset);
|
CollectAssetInfo collectAssetInfo = new CollectAssetInfo(CollectorType, bundleName, address, assetPath, isRawFilePackRule, assetTags);
|
||||||
|
|
||||||
// 注意:模拟构建模式下不需要收集依赖资源
|
// 注意:模拟构建模式下不需要收集依赖资源
|
||||||
if (command.BuildMode == EBuildMode.SimulateBuild)
|
if (command.BuildMode == EBuildMode.SimulateBuild)
|
||||||
collectAssetInfo.DependAssets = new List<string>();
|
collectAssetInfo.DependAssets = new List<string>();
|
||||||
else
|
else
|
||||||
collectAssetInfo.DependAssets = GetAllDependencies(assetPath);
|
collectAssetInfo.DependAssets = GetAllDependencies(assetPath, isRawFilePackRule);
|
||||||
|
|
||||||
return collectAssetInfo;
|
return collectAssetInfo;
|
||||||
}
|
}
|
||||||
private bool IsValidateAsset(string assetPath)
|
private bool IsValidateAsset(string assetPath, bool isRawFilePackRule)
|
||||||
{
|
{
|
||||||
if (assetPath.StartsWith("Assets/") == false && assetPath.StartsWith("Packages/") == false)
|
if (assetPath.StartsWith("Assets/") == false && assetPath.StartsWith("Packages/") == false)
|
||||||
{
|
{
|
||||||
@@ -239,10 +247,31 @@ namespace YooAsset.Editor
|
|||||||
if (type == typeof(LightingDataAsset))
|
if (type == typeof(LightingDataAsset))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// 忽略Unity无法识别的无效文件
|
// 检测原生文件是否合规
|
||||||
// 注意:只对非原生文件收集器处理
|
if (isRawFilePackRule)
|
||||||
if(PackRuleName != nameof(PackRawFile))
|
|
||||||
{
|
{
|
||||||
|
string extension = StringUtility.RemoveFirstChar(System.IO.Path.GetExtension(assetPath));
|
||||||
|
if (extension == EAssetFileExtension.unity.ToString() || extension == EAssetFileExtension.prefab.ToString() ||
|
||||||
|
extension == EAssetFileExtension.mat.ToString() || extension == EAssetFileExtension.controller.ToString() ||
|
||||||
|
extension == EAssetFileExtension.fbx.ToString() || extension == EAssetFileExtension.anim.ToString() ||
|
||||||
|
extension == EAssetFileExtension.shader.ToString())
|
||||||
|
{
|
||||||
|
UnityEngine.Debug.LogWarning($"Raw file pack rule can not support file estension : {extension}");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 注意:原生文件只支持无依赖关系的资源
|
||||||
|
string[] depends = AssetDatabase.GetDependencies(assetPath, true);
|
||||||
|
if (depends.Length != 1)
|
||||||
|
{
|
||||||
|
UnityEngine.Debug.LogWarning($"Raw file pack rule can not support estension : {extension}");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// 忽略Unity无法识别的无效文件
|
||||||
|
// 注意:只对非原生文件收集器处理
|
||||||
if (type == typeof(UnityEditor.DefaultAsset))
|
if (type == typeof(UnityEditor.DefaultAsset))
|
||||||
{
|
{
|
||||||
UnityEngine.Debug.LogWarning($"Cannot pack default asset : {assetPath}");
|
UnityEngine.Debug.LogWarning($"Cannot pack default asset : {assetPath}");
|
||||||
@@ -258,7 +287,7 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
private bool IsIgnoreFile(string fileExtension)
|
private bool IsIgnoreFile(string fileExtension)
|
||||||
{
|
{
|
||||||
foreach (var extension in YooAssetSettings.IgnoreFileExtensions)
|
foreach (var extension in DefaultFilterRule.IgnoreFileExtensions)
|
||||||
{
|
{
|
||||||
if (extension == fileExtension)
|
if (extension == fileExtension)
|
||||||
return true;
|
return true;
|
||||||
@@ -281,22 +310,25 @@ namespace YooAsset.Editor
|
|||||||
return string.Empty;
|
return string.Empty;
|
||||||
|
|
||||||
IAddressRule addressRuleInstance = AssetBundleCollectorSettingData.GetAddressRuleInstance(AddressRuleName);
|
IAddressRule addressRuleInstance = AssetBundleCollectorSettingData.GetAddressRuleInstance(AddressRuleName);
|
||||||
string adressValue = addressRuleInstance.GetAssetAddress(new AddressRuleData(assetPath, CollectPath, group.GroupName));
|
string adressValue = addressRuleInstance.GetAssetAddress(new AddressRuleData(assetPath, CollectPath, group.GroupName, UserData));
|
||||||
return adressValue;
|
return adressValue;
|
||||||
}
|
}
|
||||||
private string GetBundleName(AssetBundleCollectorGroup group, string assetPath)
|
private string GetBundleName(CollectCommand command, AssetBundleCollectorGroup group, string assetPath)
|
||||||
{
|
{
|
||||||
System.Type assetType = AssetDatabase.GetMainAssetTypeAtPath(assetPath);
|
System.Type assetType = AssetDatabase.GetMainAssetTypeAtPath(assetPath);
|
||||||
if (assetType == typeof(UnityEngine.Shader) || assetType == typeof(UnityEngine.ShaderVariantCollection))
|
if (assetType == typeof(UnityEngine.Shader) || assetType == typeof(UnityEngine.ShaderVariantCollection))
|
||||||
return EditorTools.GetRegularPath(YooAssetSettings.UnityShadersBundleName).ToLower();
|
{
|
||||||
|
// 获取着色器打包规则结果
|
||||||
// 根据规则设置获取资源包名称
|
PackRuleResult packRuleResult = DefaultPackRule.CreateShadersPackRuleResult();
|
||||||
IPackRule packRuleInstance = AssetBundleCollectorSettingData.GetPackRuleInstance(PackRuleName);
|
return packRuleResult.GetMainBundleName(command.PackageName, command.UniqueBundleName);
|
||||||
string bundleName = packRuleInstance.GetBundleName(new PackRuleData(assetPath, CollectPath, group.GroupName));
|
}
|
||||||
if(YooAssetSettingsData.Setting.RegularBundleName)
|
|
||||||
return EditorTools.GetRegularPath(bundleName).Replace('/', '_').Replace('.', '_').ToLower();
|
|
||||||
else
|
else
|
||||||
return EditorTools.GetRegularPath(bundleName).ToLower();
|
{
|
||||||
|
// 获取其它资源打包规则结果
|
||||||
|
IPackRule packRuleInstance = AssetBundleCollectorSettingData.GetPackRuleInstance(PackRuleName);
|
||||||
|
PackRuleResult packRuleResult = packRuleInstance.GetPackRuleResult(new PackRuleData(assetPath, CollectPath, group.GroupName, UserData));
|
||||||
|
return packRuleResult.GetMainBundleName(command.PackageName, command.UniqueBundleName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
private List<string> GetAssetTags(AssetBundleCollectorGroup group)
|
private List<string> GetAssetTags(AssetBundleCollectorGroup group)
|
||||||
{
|
{
|
||||||
@@ -305,13 +337,13 @@ namespace YooAsset.Editor
|
|||||||
tags.AddRange(temper);
|
tags.AddRange(temper);
|
||||||
return tags;
|
return tags;
|
||||||
}
|
}
|
||||||
private List<string> GetAllDependencies(string mainAssetPath)
|
private List<string> GetAllDependencies(string mainAssetPath, bool isRawFilePackRule)
|
||||||
{
|
{
|
||||||
List<string> result = new List<string>();
|
List<string> result = new List<string>();
|
||||||
string[] depends = AssetDatabase.GetDependencies(mainAssetPath, true);
|
string[] depends = AssetDatabase.GetDependencies(mainAssetPath, true);
|
||||||
foreach (string assetPath in depends)
|
foreach (string assetPath in depends)
|
||||||
{
|
{
|
||||||
if (IsValidateAsset(assetPath))
|
if (IsValidateAsset(assetPath, isRawFilePackRule))
|
||||||
{
|
{
|
||||||
// 注意:排除主资源对象
|
// 注意:排除主资源对象
|
||||||
if (assetPath != mainAssetPath)
|
if (assetPath != mainAssetPath)
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
public class AssetBundleCollectorConfig
|
public class AssetBundleCollectorConfig
|
||||||
{
|
{
|
||||||
public const string ConfigVersion = "2.2";
|
public const string ConfigVersion = "2.3";
|
||||||
|
|
||||||
public const string XmlVersion = "Version";
|
public const string XmlVersion = "Version";
|
||||||
public const string XmlCommon = "Common";
|
public const string XmlCommon = "Common";
|
||||||
@@ -34,6 +34,7 @@ namespace YooAsset.Editor
|
|||||||
public const string XmlAddressRule = "AddressRule";
|
public const string XmlAddressRule = "AddressRule";
|
||||||
public const string XmlPackRule = "PackRule";
|
public const string XmlPackRule = "PackRule";
|
||||||
public const string XmlFilterRule = "FilterRule";
|
public const string XmlFilterRule = "FilterRule";
|
||||||
|
public const string XmlUserData = "UserData";
|
||||||
public const string XmlAssetTags = "AssetTags";
|
public const string XmlAssetTags = "AssetTags";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -137,6 +138,8 @@ namespace YooAsset.Editor
|
|||||||
throw new Exception($"Not found attribute {XmlPackRule} in {XmlCollector}");
|
throw new Exception($"Not found attribute {XmlPackRule} in {XmlCollector}");
|
||||||
if (collectorElement.HasAttribute(XmlFilterRule) == false)
|
if (collectorElement.HasAttribute(XmlFilterRule) == false)
|
||||||
throw new Exception($"Not found attribute {XmlFilterRule} in {XmlCollector}");
|
throw new Exception($"Not found attribute {XmlFilterRule} in {XmlCollector}");
|
||||||
|
if (collectorElement.HasAttribute(XmlUserData) == false)
|
||||||
|
throw new Exception($"Not found attribute {XmlUserData} in {XmlCollector}");
|
||||||
if (collectorElement.HasAttribute(XmlAssetTags) == false)
|
if (collectorElement.HasAttribute(XmlAssetTags) == false)
|
||||||
throw new Exception($"Not found attribute {XmlAssetTags} in {XmlCollector}");
|
throw new Exception($"Not found attribute {XmlAssetTags} in {XmlCollector}");
|
||||||
|
|
||||||
@@ -147,6 +150,7 @@ namespace YooAsset.Editor
|
|||||||
collector.AddressRuleName = collectorElement.GetAttribute(XmlAddressRule);
|
collector.AddressRuleName = collectorElement.GetAttribute(XmlAddressRule);
|
||||||
collector.PackRuleName = collectorElement.GetAttribute(XmlPackRule);
|
collector.PackRuleName = collectorElement.GetAttribute(XmlPackRule);
|
||||||
collector.FilterRuleName = collectorElement.GetAttribute(XmlFilterRule);
|
collector.FilterRuleName = collectorElement.GetAttribute(XmlFilterRule);
|
||||||
|
collector.UserData = collectorElement.GetAttribute(XmlUserData);
|
||||||
collector.AssetTags = collectorElement.GetAttribute(XmlAssetTags);
|
collector.AssetTags = collectorElement.GetAttribute(XmlAssetTags);
|
||||||
group.Collectors.Add(collector);
|
group.Collectors.Add(collector);
|
||||||
}
|
}
|
||||||
@@ -219,6 +223,7 @@ namespace YooAsset.Editor
|
|||||||
collectorElement.SetAttribute(XmlAddressRule, collector.AddressRuleName);
|
collectorElement.SetAttribute(XmlAddressRule, collector.AddressRuleName);
|
||||||
collectorElement.SetAttribute(XmlPackRule, collector.PackRuleName);
|
collectorElement.SetAttribute(XmlPackRule, collector.PackRuleName);
|
||||||
collectorElement.SetAttribute(XmlFilterRule, collector.FilterRuleName);
|
collectorElement.SetAttribute(XmlFilterRule, collector.FilterRuleName);
|
||||||
|
collectorElement.SetAttribute(XmlUserData, collector.UserData);
|
||||||
collectorElement.SetAttribute(XmlAssetTags, collector.AssetTags);
|
collectorElement.SetAttribute(XmlAssetTags, collector.AssetTags);
|
||||||
groupElement.AppendChild(collectorElement);
|
groupElement.AppendChild(collectorElement);
|
||||||
}
|
}
|
||||||
@@ -320,6 +325,28 @@ namespace YooAsset.Editor
|
|||||||
return UpdateXmlConfig(xmlDoc);
|
return UpdateXmlConfig(xmlDoc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 2.2 -> 2.3
|
||||||
|
if (configVersion == "2.2")
|
||||||
|
{
|
||||||
|
// 获取所有分组元素
|
||||||
|
var groupNodeList = root.GetElementsByTagName(XmlGroup);
|
||||||
|
foreach (var groupNode in groupNodeList)
|
||||||
|
{
|
||||||
|
XmlElement groupElement = groupNode as XmlElement;
|
||||||
|
var collectorNodeList = groupElement.GetElementsByTagName(XmlCollector);
|
||||||
|
foreach (var collectorNode in collectorNodeList)
|
||||||
|
{
|
||||||
|
XmlElement collectorElement = collectorNode as XmlElement;
|
||||||
|
if (collectorElement.HasAttribute(XmlUserData) == false)
|
||||||
|
collectorElement.SetAttribute(XmlUserData, string.Empty);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 更新版本
|
||||||
|
root.SetAttribute(XmlVersion, "2.3");
|
||||||
|
return UpdateXmlConfig(xmlDoc);
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -100,8 +100,8 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
if (package.PackageName == packageName)
|
if (package.PackageName == packageName)
|
||||||
{
|
{
|
||||||
CollectCommand command = new CollectCommand(buildMode, EnableAddressable);
|
CollectCommand command = new CollectCommand(buildMode, package.PackageName, EnableAddressable, UniqueBundleName);
|
||||||
CollectResult collectResult = new CollectResult(package.PackageName, EnableAddressable, UniqueBundleName);
|
CollectResult collectResult = new CollectResult(command);
|
||||||
collectResult.SetCollectAssets(package.GetAllCollectAssets(command));
|
collectResult.SetCollectAssets(package.GetAllCollectAssets(command));
|
||||||
return collectResult;
|
return collectResult;
|
||||||
}
|
}
|
||||||
@@ -118,8 +118,8 @@ namespace YooAsset.Editor
|
|||||||
List<CollectResult> collectResultList = new List<CollectResult>(1000);
|
List<CollectResult> collectResultList = new List<CollectResult>(1000);
|
||||||
foreach (var package in Packages)
|
foreach (var package in Packages)
|
||||||
{
|
{
|
||||||
CollectCommand command = new CollectCommand(buildMode, EnableAddressable);
|
CollectCommand command = new CollectCommand(buildMode, package.PackageName, EnableAddressable, UniqueBundleName);
|
||||||
CollectResult collectResult = new CollectResult(package.PackageName, EnableAddressable, UniqueBundleName);
|
CollectResult collectResult = new CollectResult(command);
|
||||||
collectResult.SetCollectAssets(package.GetAllCollectAssets(command));
|
collectResult.SetCollectAssets(package.GetAllCollectAssets(command));
|
||||||
collectResultList.Add(collectResult);
|
collectResultList.Add(collectResult);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ namespace YooAsset.Editor
|
|||||||
List<Type> types = new List<Type>(100)
|
List<Type> types = new List<Type>(100)
|
||||||
{
|
{
|
||||||
typeof(AddressByFileName),
|
typeof(AddressByFileName),
|
||||||
typeof(AddressByCollectorAndFileName),
|
typeof(AddressByFolderAndFileName),
|
||||||
typeof(AddressByGroupAndFileName)
|
typeof(AddressByGroupAndFileName)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -594,14 +594,14 @@ namespace YooAsset.Editor
|
|||||||
var popupField = new PopupField<RuleDisplayName>(_addressRuleList, 0);
|
var popupField = new PopupField<RuleDisplayName>(_addressRuleList, 0);
|
||||||
popupField.name = "PopupField1";
|
popupField.name = "PopupField1";
|
||||||
popupField.style.unityTextAlign = TextAnchor.MiddleLeft;
|
popupField.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||||
popupField.style.width = 200;
|
popupField.style.width = 220;
|
||||||
elementBottom.Add(popupField);
|
elementBottom.Add(popupField);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
var popupField = new PopupField<RuleDisplayName>(_packRuleList, 0);
|
var popupField = new PopupField<RuleDisplayName>(_packRuleList, 0);
|
||||||
popupField.name = "PopupField2";
|
popupField.name = "PopupField2";
|
||||||
popupField.style.unityTextAlign = TextAnchor.MiddleLeft;
|
popupField.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||||
popupField.style.width = 230;
|
popupField.style.width = 220;
|
||||||
elementBottom.Add(popupField);
|
elementBottom.Add(popupField);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
@@ -611,6 +611,15 @@ namespace YooAsset.Editor
|
|||||||
popupField.style.width = 150;
|
popupField.style.width = 150;
|
||||||
elementBottom.Add(popupField);
|
elementBottom.Add(popupField);
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
var textField = new TextField();
|
||||||
|
textField.name = "TextField0";
|
||||||
|
textField.label = "UserData";
|
||||||
|
textField.style.width = 200;
|
||||||
|
elementBottom.Add(textField);
|
||||||
|
var label = textField.Q<Label>();
|
||||||
|
label.style.minWidth = 63;
|
||||||
|
}
|
||||||
{
|
{
|
||||||
var textField = new TextField();
|
var textField = new TextField();
|
||||||
textField.name = "TextField1";
|
textField.name = "TextField1";
|
||||||
@@ -750,6 +759,15 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// UserData
|
||||||
|
var textFiled0 = element.Q<TextField>("TextField0");
|
||||||
|
textFiled0.SetValueWithoutNotify(collector.UserData);
|
||||||
|
textFiled0.RegisterValueChangedCallback(evt =>
|
||||||
|
{
|
||||||
|
collector.UserData = evt.newValue;
|
||||||
|
AssetBundleCollectorSettingData.ModifyCollector(selectGroup, collector);
|
||||||
|
});
|
||||||
|
|
||||||
// Tags
|
// Tags
|
||||||
var textFiled1 = element.Q<TextField>("TextField1");
|
var textFiled1 = element.Q<TextField>("TextField1");
|
||||||
textFiled1.SetValueWithoutNotify(collector.AssetTags);
|
textFiled1.SetValueWithoutNotify(collector.AssetTags);
|
||||||
@@ -776,7 +794,7 @@ namespace YooAsset.Editor
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
CollectCommand command = new CollectCommand(EBuildMode.DryRunBuild, _enableAddressableToogle.value);
|
CollectCommand command = new CollectCommand(EBuildMode.DryRunBuild, _packageNameTxt.value, _enableAddressableToogle.value, _uniqueBundleNameToogle.value);
|
||||||
collectAssetInfos = collector.GetAllCollectAssets(command, group);
|
collectAssetInfos = collector.GetAllCollectAssets(command, group);
|
||||||
}
|
}
|
||||||
catch (System.Exception e)
|
catch (System.Exception e)
|
||||||
@@ -796,7 +814,7 @@ namespace YooAsset.Editor
|
|||||||
if (_enableAddressableToogle.value)
|
if (_enableAddressableToogle.value)
|
||||||
{
|
{
|
||||||
IAddressRule instance = AssetBundleCollectorSettingData.GetAddressRuleInstance(collector.AddressRuleName);
|
IAddressRule instance = AssetBundleCollectorSettingData.GetAddressRuleInstance(collector.AddressRuleName);
|
||||||
AddressRuleData ruleData = new AddressRuleData(collectAssetInfo.AssetPath, collector.CollectPath, group.GroupName);
|
AddressRuleData ruleData = new AddressRuleData(collectAssetInfo.AssetPath, collector.CollectPath, group.GroupName, collector.UserData);
|
||||||
string addressValue = instance.GetAssetAddress(ruleData);
|
string addressValue = instance.GetAssetAddress(ruleData);
|
||||||
showInfo = $"[{addressValue}] {showInfo}";
|
showInfo = $"[{addressValue}] {showInfo}";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,30 +25,30 @@ namespace YooAsset.Editor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string AssetPath { private set; get; }
|
public string AssetPath { private set; get; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 资源分类标签
|
|
||||||
/// </summary>
|
|
||||||
public List<string> AssetTags { private set; get; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 是否为原生资源
|
/// 是否为原生资源
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IsRawAsset { private set; get; }
|
public bool IsRawAsset { private set; get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 资源分类标签
|
||||||
|
/// </summary>
|
||||||
|
public List<string> AssetTags { private set; get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 依赖的资源列表
|
/// 依赖的资源列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<string> DependAssets = new List<string>();
|
public List<string> DependAssets = new List<string>();
|
||||||
|
|
||||||
|
|
||||||
public CollectAssetInfo(ECollectorType collectorType, string bundleName, string address, string assetPath, List<string> assetTags, bool isRawAsset)
|
public CollectAssetInfo(ECollectorType collectorType, string bundleName, string address, string assetPath, bool isRawAsset, List<string> assetTags)
|
||||||
{
|
{
|
||||||
CollectorType = collectorType;
|
CollectorType = collectorType;
|
||||||
BundleName = bundleName;
|
BundleName = bundleName;
|
||||||
Address = address;
|
Address = address;
|
||||||
AssetPath = assetPath;
|
AssetPath = assetPath;
|
||||||
AssetTags = assetTags;
|
|
||||||
IsRawAsset = isRawAsset;
|
IsRawAsset = isRawAsset;
|
||||||
|
AssetTags = assetTags;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -8,15 +8,27 @@ namespace YooAsset.Editor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public EBuildMode BuildMode { private set; get; }
|
public EBuildMode BuildMode { private set; get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 包裹名称
|
||||||
|
/// </summary>
|
||||||
|
public string PackageName { private set; get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 是否启用可寻址资源定位
|
/// 是否启用可寻址资源定位
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool EnableAddressable { private set; get; }
|
public bool EnableAddressable { private set; get; }
|
||||||
|
|
||||||
public CollectCommand(EBuildMode buildMode, bool enableAddressable)
|
/// <summary>
|
||||||
|
/// 资源包名唯一化
|
||||||
|
/// </summary>
|
||||||
|
public bool UniqueBundleName { private set; get; }
|
||||||
|
|
||||||
|
public CollectCommand(EBuildMode buildMode, string packageName, bool enableAddressable, bool uniqueBundleName)
|
||||||
{
|
{
|
||||||
BuildMode = buildMode;
|
BuildMode = buildMode;
|
||||||
|
PackageName = packageName;
|
||||||
EnableAddressable = enableAddressable;
|
EnableAddressable = enableAddressable;
|
||||||
|
UniqueBundleName = uniqueBundleName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -6,19 +6,14 @@ namespace YooAsset.Editor
|
|||||||
public class CollectResult
|
public class CollectResult
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 包裹名称
|
/// 收集命令
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string PackageName { private set; get; }
|
public CollectCommand Command { private set; get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 是否启用可寻址资源定位
|
/// 着色器统一全名称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool EnableAddressable { private set; get; }
|
public string ShadersBundleName { private set; get; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 资源包名唯一化
|
|
||||||
/// </summary>
|
|
||||||
public bool UniqueBundleName { private set; get; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 收集的资源信息列表
|
/// 收集的资源信息列表
|
||||||
@@ -26,11 +21,13 @@ namespace YooAsset.Editor
|
|||||||
public List<CollectAssetInfo> CollectAssets { private set; get; }
|
public List<CollectAssetInfo> CollectAssets { private set; get; }
|
||||||
|
|
||||||
|
|
||||||
public CollectResult(string packageName, bool enableAddressable, bool uniqueBundleName)
|
public CollectResult(CollectCommand command)
|
||||||
{
|
{
|
||||||
PackageName = packageName;
|
Command = command;
|
||||||
EnableAddressable = enableAddressable;
|
|
||||||
UniqueBundleName = uniqueBundleName;
|
// 着色器统一全名称
|
||||||
|
var packRuleResult = DefaultPackRule.CreateShadersPackRuleResult();
|
||||||
|
ShadersBundleName = packRuleResult.GetMainBundleName(command.PackageName, command.UniqueBundleName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetCollectAssets(List<CollectAssetInfo> collectAssets)
|
public void SetCollectAssets(List<CollectAssetInfo> collectAssets)
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
[DisplayName("以文件名称为定位地址")]
|
[DisplayName("定位地址: 文件名")]
|
||||||
public class AddressByFileName : IAddressRule
|
public class AddressByFileName : IAddressRule
|
||||||
{
|
{
|
||||||
string IAddressRule.GetAssetAddress(AddressRuleData data)
|
string IAddressRule.GetAssetAddress(AddressRuleData data)
|
||||||
@@ -11,7 +11,7 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[DisplayName("以分组名称+文件名称为定位地址")]
|
[DisplayName("定位地址: 分组名+文件名")]
|
||||||
public class AddressByGroupAndFileName : IAddressRule
|
public class AddressByGroupAndFileName : IAddressRule
|
||||||
{
|
{
|
||||||
string IAddressRule.GetAssetAddress(AddressRuleData data)
|
string IAddressRule.GetAssetAddress(AddressRuleData data)
|
||||||
@@ -21,8 +21,8 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[DisplayName("以收集器名称+文件名称为定位地址")]
|
[DisplayName("定位地址: 文件夹名+文件名")]
|
||||||
public class AddressByCollectorAndFileName : IAddressRule
|
public class AddressByFolderAndFileName : IAddressRule
|
||||||
{
|
{
|
||||||
string IAddressRule.GetAssetAddress(AddressRuleData data)
|
string IAddressRule.GetAssetAddress(AddressRuleData data)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4,6 +4,14 @@ using System.IO;
|
|||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
|
public class DefaultFilterRule
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 忽略的文件类型
|
||||||
|
/// </summary>
|
||||||
|
public static readonly string[] IgnoreFileExtensions = { "", ".so", ".dll", ".cs", ".js", ".boo", ".meta", ".cginc", ".hlsl" };
|
||||||
|
}
|
||||||
|
|
||||||
[DisplayName("收集所有资源")]
|
[DisplayName("收集所有资源")]
|
||||||
public class CollectAll : IFilterRule
|
public class CollectAll : IFilterRule
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4,18 +4,50 @@ using UnityEditor;
|
|||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
|
public class DefaultPackRule
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// AssetBundle文件的后缀名
|
||||||
|
/// </summary>
|
||||||
|
public const string AssetBundleFileExtension = "bundle";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 原生文件的后缀名
|
||||||
|
/// </summary>
|
||||||
|
public const string RawFileExtension = "rawfile";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Unity着色器资源包名称
|
||||||
|
/// </summary>
|
||||||
|
public const string ShadersBundleName = "unityshaders";
|
||||||
|
|
||||||
|
|
||||||
|
public static PackRuleResult CreateShadersPackRuleResult()
|
||||||
|
{
|
||||||
|
PackRuleResult result = new PackRuleResult(ShadersBundleName, AssetBundleFileExtension);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 以文件路径作为资源包名
|
/// 以文件路径作为资源包名
|
||||||
/// 注意:每个文件独自打资源包
|
/// 注意:每个文件独自打资源包
|
||||||
/// 例如:"Assets/UIPanel/Shop/Image/backgroud.png" --> "assets_uipanel_shop_image_backgroud.bundle"
|
/// 例如:"Assets/UIPanel/Shop/Image/backgroud.png" --> "assets_uipanel_shop_image_backgroud.bundle"
|
||||||
/// 例如:"Assets/UIPanel/Shop/View/main.prefab" --> "assets_uipanel_shop_view_main.bundle"
|
/// 例如:"Assets/UIPanel/Shop/View/main.prefab" --> "assets_uipanel_shop_view_main.bundle"
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DisplayName("以文件路径作为资源包名")]
|
[DisplayName("资源包名: 文件路径")]
|
||||||
public class PackSeparately : IPackRule
|
public class PackSeparately : IPackRule
|
||||||
{
|
{
|
||||||
string IPackRule.GetBundleName(PackRuleData data)
|
PackRuleResult IPackRule.GetPackRuleResult(PackRuleData data)
|
||||||
{
|
{
|
||||||
return StringUtility.RemoveExtension(data.AssetPath);
|
string bundleName = StringUtility.RemoveExtension(data.AssetPath);
|
||||||
|
PackRuleResult result = new PackRuleResult(bundleName, DefaultPackRule.AssetBundleFileExtension);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IPackRule.IsRawFilePackRule()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -25,14 +57,21 @@ namespace YooAsset.Editor
|
|||||||
/// 例如:"Assets/UIPanel/Shop/Image/backgroud.png" --> "assets_uipanel_shop_image.bundle"
|
/// 例如:"Assets/UIPanel/Shop/Image/backgroud.png" --> "assets_uipanel_shop_image.bundle"
|
||||||
/// 例如:"Assets/UIPanel/Shop/View/main.prefab" --> "assets_uipanel_shop_view.bundle"
|
/// 例如:"Assets/UIPanel/Shop/View/main.prefab" --> "assets_uipanel_shop_view.bundle"
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DisplayName("以父类文件夹路径作为资源包名")]
|
[DisplayName("资源包名: 父类文件夹路径")]
|
||||||
public class PackDirectory : IPackRule
|
public class PackDirectory : IPackRule
|
||||||
{
|
{
|
||||||
public static PackDirectory StaticPackRule = new PackDirectory();
|
public static PackDirectory StaticPackRule = new PackDirectory();
|
||||||
|
|
||||||
string IPackRule.GetBundleName(PackRuleData data)
|
PackRuleResult IPackRule.GetPackRuleResult(PackRuleData data)
|
||||||
{
|
{
|
||||||
return Path.GetDirectoryName(data.AssetPath);
|
string bundleName = Path.GetDirectoryName(data.AssetPath);
|
||||||
|
PackRuleResult result = new PackRuleResult(bundleName, DefaultPackRule.AssetBundleFileExtension);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IPackRule.IsRawFilePackRule()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -43,10 +82,10 @@ namespace YooAsset.Editor
|
|||||||
/// 例如:"Assets/UIPanel/Shop/Image/backgroud.png" --> "assets_uipanel_shop.bundle"
|
/// 例如:"Assets/UIPanel/Shop/Image/backgroud.png" --> "assets_uipanel_shop.bundle"
|
||||||
/// 例如:"Assets/UIPanel/Shop/View/main.prefab" --> "assets_uipanel_shop.bundle"
|
/// 例如:"Assets/UIPanel/Shop/View/main.prefab" --> "assets_uipanel_shop.bundle"
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DisplayName("以收集器路径下顶级文件夹为资源包名")]
|
[DisplayName("资源包名: 收集器下顶级文件夹路径")]
|
||||||
public class PackTopDirectory : IPackRule
|
public class PackTopDirectory : IPackRule
|
||||||
{
|
{
|
||||||
string IPackRule.GetBundleName(PackRuleData data)
|
PackRuleResult IPackRule.GetPackRuleResult(PackRuleData data)
|
||||||
{
|
{
|
||||||
string assetPath = data.AssetPath.Replace(data.CollectPath, string.Empty);
|
string assetPath = data.AssetPath.Replace(data.CollectPath, string.Empty);
|
||||||
assetPath = assetPath.TrimStart('/');
|
assetPath = assetPath.TrimStart('/');
|
||||||
@@ -56,33 +95,48 @@ namespace YooAsset.Editor
|
|||||||
if (Path.HasExtension(splits[0]))
|
if (Path.HasExtension(splits[0]))
|
||||||
throw new Exception($"Not found root directory : {assetPath}");
|
throw new Exception($"Not found root directory : {assetPath}");
|
||||||
string bundleName = $"{data.CollectPath}/{splits[0]}";
|
string bundleName = $"{data.CollectPath}/{splits[0]}";
|
||||||
return bundleName;
|
PackRuleResult result = new PackRuleResult(bundleName, DefaultPackRule.AssetBundleFileExtension);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new Exception($"Not found root directory : {assetPath}");
|
throw new Exception($"Not found root directory : {assetPath}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IPackRule.IsRawFilePackRule()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 以收集器路径作为资源包名
|
/// 以收集器路径作为资源包名
|
||||||
/// 注意:收集的所有文件打进一个资源包
|
/// 注意:收集的所有文件打进一个资源包
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DisplayName("以收集器路径作为资源包名")]
|
[DisplayName("资源包名: 收集器路径")]
|
||||||
public class PackCollector : IPackRule
|
public class PackCollector : IPackRule
|
||||||
{
|
{
|
||||||
string IPackRule.GetBundleName(PackRuleData data)
|
PackRuleResult IPackRule.GetPackRuleResult(PackRuleData data)
|
||||||
{
|
{
|
||||||
|
string bundleName;
|
||||||
string collectPath = data.CollectPath;
|
string collectPath = data.CollectPath;
|
||||||
if (AssetDatabase.IsValidFolder(collectPath))
|
if (AssetDatabase.IsValidFolder(collectPath))
|
||||||
{
|
{
|
||||||
return collectPath;
|
bundleName = collectPath;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return StringUtility.RemoveExtension(collectPath);
|
bundleName = StringUtility.RemoveExtension(collectPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PackRuleResult result = new PackRuleResult(bundleName, DefaultPackRule.AssetBundleFileExtension);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IPackRule.IsRawFilePackRule()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,51 +144,55 @@ namespace YooAsset.Editor
|
|||||||
/// 以分组名称作为资源包名
|
/// 以分组名称作为资源包名
|
||||||
/// 注意:收集的所有文件打进一个资源包
|
/// 注意:收集的所有文件打进一个资源包
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DisplayName("以分组名称作为资源包名")]
|
[DisplayName("资源包名: 分组名称")]
|
||||||
public class PackGroup : IPackRule
|
public class PackGroup : IPackRule
|
||||||
{
|
{
|
||||||
string IPackRule.GetBundleName(PackRuleData data)
|
PackRuleResult IPackRule.GetPackRuleResult(PackRuleData data)
|
||||||
{
|
{
|
||||||
return data.GroupName;
|
string bundleName = data.GroupName;
|
||||||
|
PackRuleResult result = new PackRuleResult(bundleName, DefaultPackRule.AssetBundleFileExtension);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IPackRule.IsRawFilePackRule()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 打包原生文件
|
/// 打包原生文件
|
||||||
/// 注意:原生文件打包支持:图片,音频,视频,文本
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DisplayName("打包原生文件")]
|
[DisplayName("打包原生文件")]
|
||||||
public class PackRawFile : IPackRule
|
public class PackRawFile : IPackRule
|
||||||
{
|
{
|
||||||
string IPackRule.GetBundleName(PackRuleData data)
|
PackRuleResult IPackRule.GetPackRuleResult(PackRuleData data)
|
||||||
{
|
{
|
||||||
string extension = StringUtility.RemoveFirstChar(Path.GetExtension(data.AssetPath));
|
string bundleName = data.AssetPath;
|
||||||
if (extension == EAssetFileExtension.unity.ToString() || extension == EAssetFileExtension.prefab.ToString() ||
|
PackRuleResult result = new PackRuleResult(bundleName, DefaultPackRule.RawFileExtension);
|
||||||
extension == EAssetFileExtension.mat.ToString() || extension == EAssetFileExtension.controller.ToString() ||
|
return result;
|
||||||
extension == EAssetFileExtension.fbx.ToString() || extension == EAssetFileExtension.anim.ToString() ||
|
}
|
||||||
extension == EAssetFileExtension.shader.ToString())
|
|
||||||
{
|
|
||||||
throw new Exception($"{nameof(PackRawFile)} is not support file estension : {extension}");
|
|
||||||
}
|
|
||||||
|
|
||||||
// 注意:原生文件只支持无依赖关系的资源
|
bool IPackRule.IsRawFilePackRule()
|
||||||
string[] depends = AssetDatabase.GetDependencies(data.AssetPath, true);
|
{
|
||||||
if (depends.Length != 1)
|
return true;
|
||||||
throw new Exception($"{nameof(PackRawFile)} is not support estension : {extension}");
|
|
||||||
|
|
||||||
return data.AssetPath;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 打包着色器变种集合
|
/// 打包着色器变种集合
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DisplayName("打包着色器变种集合")]
|
[DisplayName("打包着色器变种集合文件")]
|
||||||
public class PackShaderVariants : IPackRule
|
public class PackShaderVariants : IPackRule
|
||||||
{
|
{
|
||||||
public string GetBundleName(PackRuleData data)
|
public PackRuleResult GetPackRuleResult(PackRuleData data)
|
||||||
{
|
{
|
||||||
return YooAssetSettings.UnityShadersBundleName;
|
return DefaultPackRule.CreateShadersPackRuleResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IPackRule.IsRawFilePackRule()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -6,12 +6,14 @@ namespace YooAsset.Editor
|
|||||||
public string AssetPath;
|
public string AssetPath;
|
||||||
public string CollectPath;
|
public string CollectPath;
|
||||||
public string GroupName;
|
public string GroupName;
|
||||||
|
public string UserData;
|
||||||
|
|
||||||
public AddressRuleData(string assetPath, string collectPath, string groupName)
|
public AddressRuleData(string assetPath, string collectPath, string groupName, string userData)
|
||||||
{
|
{
|
||||||
AssetPath = assetPath;
|
AssetPath = assetPath;
|
||||||
CollectPath = collectPath;
|
CollectPath = collectPath;
|
||||||
GroupName = groupName;
|
GroupName = groupName;
|
||||||
|
UserData = userData;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,18 +6,61 @@ namespace YooAsset.Editor
|
|||||||
public string AssetPath;
|
public string AssetPath;
|
||||||
public string CollectPath;
|
public string CollectPath;
|
||||||
public string GroupName;
|
public string GroupName;
|
||||||
|
public string UserData;
|
||||||
|
|
||||||
public PackRuleData(string assetPath)
|
public PackRuleData(string assetPath)
|
||||||
{
|
{
|
||||||
AssetPath = assetPath;
|
AssetPath = assetPath;
|
||||||
CollectPath = string.Empty;
|
CollectPath = string.Empty;
|
||||||
GroupName = string.Empty;
|
GroupName = string.Empty;
|
||||||
|
UserData = string.Empty;
|
||||||
}
|
}
|
||||||
public PackRuleData(string assetPath, string collectPath, string groupName)
|
public PackRuleData(string assetPath, string collectPath, string groupName, string userData)
|
||||||
{
|
{
|
||||||
AssetPath = assetPath;
|
AssetPath = assetPath;
|
||||||
CollectPath = collectPath;
|
CollectPath = collectPath;
|
||||||
GroupName = groupName;
|
GroupName = groupName;
|
||||||
|
UserData = userData;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public struct PackRuleResult
|
||||||
|
{
|
||||||
|
private readonly string _bundleName;
|
||||||
|
private readonly string _bundleExtension;
|
||||||
|
|
||||||
|
public PackRuleResult(string bundleName, string bundleExtension)
|
||||||
|
{
|
||||||
|
_bundleName = bundleName;
|
||||||
|
_bundleExtension = bundleExtension;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取主资源包全名称
|
||||||
|
/// </summary>
|
||||||
|
public string GetMainBundleName(string packageName, bool uniqueBundleName)
|
||||||
|
{
|
||||||
|
string fullName;
|
||||||
|
string bundleName = EditorTools.GetRegularPath(_bundleName).Replace('/', '_').Replace('.', '_').ToLower();
|
||||||
|
if (uniqueBundleName)
|
||||||
|
fullName = $"{packageName}_{bundleName}.{_bundleExtension}";
|
||||||
|
else
|
||||||
|
fullName = $"{bundleName}.{_bundleExtension}";
|
||||||
|
return fullName.ToLower();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取共享资源包全名称
|
||||||
|
/// </summary>
|
||||||
|
public string GetShareBundleName(string packageName, bool uniqueBundleName)
|
||||||
|
{
|
||||||
|
string fullName;
|
||||||
|
string bundleName = EditorTools.GetRegularPath(_bundleName).Replace('/', '_').Replace('.', '_').ToLower();
|
||||||
|
if (uniqueBundleName)
|
||||||
|
fullName = $"{packageName}_share_{bundleName}.{_bundleExtension}";
|
||||||
|
else
|
||||||
|
fullName = $"share_{bundleName}.{_bundleExtension}";
|
||||||
|
return fullName.ToLower();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -27,8 +70,13 @@ namespace YooAsset.Editor
|
|||||||
public interface IPackRule
|
public interface IPackRule
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取资源打包所属的资源包名称
|
/// 获取打包规则结果
|
||||||
/// </summary>
|
/// </summary>
|
||||||
string GetBundleName(PackRuleData data);
|
PackRuleResult GetPackRuleResult(PackRuleData data);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否为原生文件打包规则
|
||||||
|
/// </summary>
|
||||||
|
bool IsRawFilePackRule();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="False">
|
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements">
|
||||||
<ui:VisualElement name="TopGroup" style="flex-grow: 1; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 2px; margin-bottom: 1px; display: flex;">
|
<ui:VisualElement name="TopGroup" style="flex-grow: 1; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 2px; margin-bottom: 1px; display: flex;">
|
||||||
<uie:Toolbar name="TopBar" style="height: 25px; margin-left: 1px; margin-right: 1px;">
|
<uie:Toolbar name="TopBar" style="height: 25px; margin-left: 1px; margin-right: 1px;">
|
||||||
<uie:ToolbarButton text="Asset Path" display-tooltip-when-elided="true" name="TopBar1" style="width: 280px; -unity-text-align: middle-left; flex-grow: 1;" />
|
<uie:ToolbarButton text="Asset Path" display-tooltip-when-elided="true" name="TopBar1" style="width: 280px; -unity-text-align: middle-left; flex-grow: 1;" />
|
||||||
<uie:ToolbarButton text="Main Bundle" display-tooltip-when-elided="true" name="TopBar2" style="width: 145px; -unity-text-align: middle-left; flex-grow: 1;" />
|
<uie:ToolbarButton text="Main Bundle" display-tooltip-when-elided="true" name="TopBar2" style="width: 145px; -unity-text-align: middle-left; flex-grow: 1;" />
|
||||||
</uie:Toolbar>
|
</uie:Toolbar>
|
||||||
<ui:ListView focusable="true" name="TopListView" item-height="18" virtualization-method="DynamicHeight" style="flex-grow: 1;" />
|
<ui:ListView focusable="true" name="TopListView" item-height="18" virtualization-method="DynamicHeight" style="flex-grow: 1; flex-basis: 60px;" />
|
||||||
</ui:VisualElement>
|
</ui:VisualElement>
|
||||||
<ui:VisualElement name="BottomGroup" style="height: 200px; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 1px; margin-bottom: 1px; display: flex;">
|
<ui:VisualElement name="BottomGroup" style="height: 200px; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 1px; margin-bottom: 1px; display: flex;">
|
||||||
<uie:Toolbar name="BottomBar" style="height: 25px; margin-left: 1px; margin-right: 1px;">
|
<uie:Toolbar name="BottomBar" style="height: 25px; margin-left: 1px; margin-right: 1px;">
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="False">
|
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements">
|
||||||
<ui:VisualElement name="Viewer" style="flex-grow: 1; display: flex;">
|
<ui:VisualElement name="Viewer" style="flex-grow: 1; display: flex;">
|
||||||
<ui:VisualElement name="TopGroup" style="flex-grow: 1; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 2px; margin-bottom: 1px; display: flex;">
|
<ui:VisualElement name="TopGroup" style="flex-grow: 1; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 2px; margin-bottom: 1px; display: flex;">
|
||||||
<uie:Toolbar name="TopBar" style="height: 25px; margin-left: 1px; margin-right: 1px;">
|
<uie:Toolbar name="TopBar" style="height: 25px; margin-left: 1px; margin-right: 1px;">
|
||||||
@@ -8,7 +8,7 @@
|
|||||||
<uie:ToolbarButton text="LoadMethod" display-tooltip-when-elided="true" name="TopBar4" style="width: 150px; -unity-text-align: middle-left; flex-grow: 0;" />
|
<uie:ToolbarButton text="LoadMethod" display-tooltip-when-elided="true" name="TopBar4" style="width: 150px; -unity-text-align: middle-left; flex-grow: 0;" />
|
||||||
<uie:ToolbarButton text="Tags" display-tooltip-when-elided="true" name="TopBar5" style="width: 80px; -unity-text-align: middle-left; flex-grow: 1;" />
|
<uie:ToolbarButton text="Tags" display-tooltip-when-elided="true" name="TopBar5" style="width: 80px; -unity-text-align: middle-left; flex-grow: 1;" />
|
||||||
</uie:Toolbar>
|
</uie:Toolbar>
|
||||||
<ui:ListView focusable="true" name="TopListView" item-height="18" virtualization-method="DynamicHeight" style="flex-grow: 1;" />
|
<ui:ListView focusable="true" name="TopListView" item-height="18" virtualization-method="DynamicHeight" style="flex-grow: 1; flex-basis: 60px;" />
|
||||||
</ui:VisualElement>
|
</ui:VisualElement>
|
||||||
<ui:VisualElement name="BottomGroup" style="height: 200px; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 1px; margin-bottom: 1px; display: flex;">
|
<ui:VisualElement name="BottomGroup" style="height: 200px; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 1px; margin-bottom: 1px; display: flex;">
|
||||||
<uie:Toolbar name="BottomBar" style="height: 25px; margin-left: 1px; margin-right: 1px;">
|
<uie:Toolbar name="BottomBar" style="height: 25px; margin-left: 1px; margin-right: 1px;">
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ namespace YooAsset.Editor
|
|||||||
private TemplateContainer _root;
|
private TemplateContainer _root;
|
||||||
|
|
||||||
private ListView _listView;
|
private ListView _listView;
|
||||||
private BuildReport _buildReport;
|
|
||||||
private readonly List<ItemWrapper> _items = new List<ItemWrapper>();
|
private readonly List<ItemWrapper> _items = new List<ItemWrapper>();
|
||||||
|
|
||||||
|
|
||||||
@@ -55,14 +54,12 @@ namespace YooAsset.Editor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void FillViewData(BuildReport buildReport)
|
public void FillViewData(BuildReport buildReport)
|
||||||
{
|
{
|
||||||
_buildReport = buildReport;
|
|
||||||
|
|
||||||
_items.Clear();
|
_items.Clear();
|
||||||
|
|
||||||
_items.Add(new ItemWrapper("YooAsset版本", buildReport.Summary.YooVersion));
|
_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.BuildDate));
|
_items.Add(new ItemWrapper("构建时间", buildReport.Summary.BuildDate));
|
||||||
_items.Add(new ItemWrapper("构建耗时", $"{buildReport.Summary.BuildSeconds}秒"));
|
_items.Add(new ItemWrapper("构建耗时", ConvertTime(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.BuildPipeline}"));
|
||||||
_items.Add(new ItemWrapper("构建模式", $"{buildReport.Summary.BuildMode}"));
|
_items.Add(new ItemWrapper("构建模式", $"{buildReport.Summary.BuildMode}"));
|
||||||
@@ -154,16 +151,23 @@ namespace YooAsset.Editor
|
|||||||
label2.text = itemWrapper.Value;
|
label2.text = itemWrapper.Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private string ConvertTime(int time)
|
||||||
|
{
|
||||||
|
if (time <= 60)
|
||||||
|
{
|
||||||
|
return $"{time}秒钟";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int minute = time / 60;
|
||||||
|
return $"{minute}分钟";
|
||||||
|
}
|
||||||
|
}
|
||||||
private string ConvertSize(long size)
|
private string ConvertSize(long size)
|
||||||
{
|
{
|
||||||
if (size == 0)
|
if (size == 0)
|
||||||
return "0";
|
return "0";
|
||||||
if (size < 1024)
|
return EditorUtility.FormatBytes(size);
|
||||||
return $"{size} Bytes";
|
|
||||||
else if (size < 1024 * 1024)
|
|
||||||
return $"{(int)(size / 1024)} KB";
|
|
||||||
else
|
|
||||||
return $"{(int)(size / (1024 * 1024))} MB";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -341,6 +341,14 @@ namespace YooAsset
|
|||||||
_providers.Remove(provider);
|
_providers.Remove(provider);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
internal bool CheckBundleCanDestroy(int bundleID)
|
||||||
|
{
|
||||||
|
string bundleName = BundleServices.GetBundleName(bundleID);
|
||||||
|
BundleLoaderBase loader = TryGetAssetBundleLoader(bundleName);
|
||||||
|
if (loader == null)
|
||||||
|
return true;
|
||||||
|
return loader.CanDestroy();
|
||||||
|
}
|
||||||
|
|
||||||
private BundleLoaderBase CreateAssetBundleLoaderInternal(BundleInfo bundleInfo)
|
private BundleLoaderBase CreateAssetBundleLoaderInternal(BundleInfo bundleInfo)
|
||||||
{
|
{
|
||||||
@@ -350,7 +358,7 @@ namespace YooAsset
|
|||||||
return loader;
|
return loader;
|
||||||
|
|
||||||
// 新增下载需求
|
// 新增下载需求
|
||||||
#if !UNITY_WEBGL
|
#if UNITY_WEBGL
|
||||||
if (bundleInfo.Bundle.IsRawFile)
|
if (bundleInfo.Bundle.IsRawFile)
|
||||||
loader = new RawBundleFileLoader(this, bundleInfo);
|
loader = new RawBundleFileLoader(this, bundleInfo);
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -122,6 +122,15 @@ namespace YooAsset
|
|||||||
if (RefCount > _providers.Count)
|
if (RefCount > _providers.Count)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// 条件3:检查依赖链上的资源包
|
||||||
|
// 依赖该资源包的所有资源包可以销毁
|
||||||
|
// 注意:互相引用的资源包无法卸载!
|
||||||
|
foreach (var bundleID in MainBundleInfo.Bundle.ReferenceIDs)
|
||||||
|
{
|
||||||
|
if (Impl.CheckBundleCanDestroy(bundleID) == false)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// 销毁所有Providers
|
// 销毁所有Providers
|
||||||
foreach (var provider in _providers)
|
foreach (var provider in _providers)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ namespace YooAsset
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 初始化时的验证级别
|
/// 初始化时的验证级别
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static EVerifyLevel InitVerifyLevel { set; get; } = EVerifyLevel.Low;
|
public static EVerifyLevel InitVerifyLevel { set; get; } = EVerifyLevel.Middle;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 清空所有数据
|
/// 清空所有数据
|
||||||
@@ -37,6 +37,7 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static void RecordFile(string packageName, string cacheGUID, PackageCache.RecordWrapper wrapper)
|
public static void RecordFile(string packageName, string cacheGUID, PackageCache.RecordWrapper wrapper)
|
||||||
{
|
{
|
||||||
|
//YooLogger.Log($"Record file : {packageName} = {cacheGUID}");
|
||||||
var cache = GetOrCreateCache(packageName);
|
var cache = GetOrCreateCache(packageName);
|
||||||
cache.Record(cacheGUID, wrapper);
|
cache.Record(cacheGUID, wrapper);
|
||||||
}
|
}
|
||||||
@@ -69,31 +70,41 @@ namespace YooAsset
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 验证缓存文件(子线程内操作)
|
/// 验证缓存文件(子线程内操作)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static EVerifyResult VerifyingCacheFile(VerifyElement element, EVerifyLevel verifyLevel)
|
public static EVerifyResult VerifyingCacheFile(VerifyElement element)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
string infoFilePath = element.InfoFilePath;
|
if (InitVerifyLevel == EVerifyLevel.Low)
|
||||||
if (File.Exists(infoFilePath) == false)
|
{
|
||||||
return EVerifyResult.InfoFileNotExisted;
|
if (File.Exists(element.InfoFilePath) == false)
|
||||||
|
return EVerifyResult.InfoFileNotExisted;
|
||||||
|
if (File.Exists(element.DataFilePath) == false)
|
||||||
|
return EVerifyResult.DataFileNotExisted;
|
||||||
|
return EVerifyResult.Succeed;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (File.Exists(element.InfoFilePath) == false)
|
||||||
|
return EVerifyResult.InfoFileNotExisted;
|
||||||
|
|
||||||
// 解析信息文件获取验证数据
|
// 解析信息文件获取验证数据
|
||||||
CacheFileInfo.ReadInfoFromFile(infoFilePath, out element.DataFileCRC, out element.DataFileSize);
|
CacheFileInfo.ReadInfoFromFile(element.InfoFilePath, out element.DataFileCRC, out element.DataFileSize);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
return EVerifyResult.Exception;
|
return EVerifyResult.Exception;
|
||||||
}
|
}
|
||||||
|
|
||||||
return VerifyingInternal(element.DataFilePath, element.DataFileSize, element.DataFileCRC, verifyLevel);
|
return VerifyingInternal(element.DataFilePath, element.DataFileSize, element.DataFileCRC, InitVerifyLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 验证下载文件
|
/// 验证下载文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static EVerifyResult VerifyingTempFile(PatchBundle patchBundle, EVerifyLevel verifyLevel)
|
public static EVerifyResult VerifyingTempFile(PatchBundle patchBundle)
|
||||||
{
|
{
|
||||||
return VerifyingInternal(patchBundle.TempDataFilePath, patchBundle.FileSize, patchBundle.FileCRC, verifyLevel);
|
return VerifyingInternal(patchBundle.TempDataFilePath, patchBundle.FileSize, patchBundle.FileCRC, EVerifyLevel.High);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -7,10 +7,15 @@ namespace YooAsset
|
|||||||
public enum EVerifyLevel
|
public enum EVerifyLevel
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 验证文件大小
|
/// 验证文件存在
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Low,
|
Low,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 验证文件大小
|
||||||
|
/// </summary>
|
||||||
|
Middle,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 验证文件大小和CRC
|
/// 验证文件大小和CRC
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -67,8 +67,23 @@ namespace YooAsset
|
|||||||
if (CacheSystem.IsCached(_packageName, cacheGUID))
|
if (CacheSystem.IsCached(_packageName, cacheGUID))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
// 获取数据文件的后缀名
|
||||||
|
string dataFileExtension = string.Empty;
|
||||||
|
var fileInfos = fileFoder.GetFiles();
|
||||||
|
foreach (var fileInfo in fileInfos)
|
||||||
|
{
|
||||||
|
if (fileInfo.Extension == ".temp")
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (fileInfo.Name.StartsWith(YooAssetSettings.CacheBundleDataFileName))
|
||||||
|
{
|
||||||
|
dataFileExtension = fileInfo.Extension;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
string fileRootPath = fileFoder.FullName;
|
string fileRootPath = fileFoder.FullName;
|
||||||
string dataFilePath = $"{fileRootPath}/{ YooAssetSettings.CacheBundleDataFileName}";
|
string dataFilePath = $"{fileRootPath}/{ YooAssetSettings.CacheBundleDataFileName}{dataFileExtension}";
|
||||||
string infoFilePath = $"{fileRootPath}/{ YooAssetSettings.CacheBundleInfoFileName}";
|
string infoFilePath = $"{fileRootPath}/{ YooAssetSettings.CacheBundleInfoFileName}";
|
||||||
VerifyElement element = new VerifyElement(_packageName, cacheGUID, fileRootPath, dataFilePath, infoFilePath);
|
VerifyElement element = new VerifyElement(_packageName, cacheGUID, fileRootPath, dataFilePath, infoFilePath);
|
||||||
result.Add(element);
|
result.Add(element);
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ namespace YooAsset
|
|||||||
private void VerifyInThread(object obj)
|
private void VerifyInThread(object obj)
|
||||||
{
|
{
|
||||||
VerifyElement element = (VerifyElement)obj;
|
VerifyElement element = (VerifyElement)obj;
|
||||||
element.Result = CacheSystem.VerifyingCacheFile(element, CacheSystem.InitVerifyLevel);
|
element.Result = CacheSystem.VerifyingCacheFile(element);
|
||||||
_syncContext.Post(VerifyCallback, element);
|
_syncContext.Post(VerifyCallback, element);
|
||||||
}
|
}
|
||||||
private void VerifyCallback(object obj)
|
private void VerifyCallback(object obj)
|
||||||
@@ -139,12 +139,8 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
_failedCount++;
|
_failedCount++;
|
||||||
|
|
||||||
// 删除验证失败的缓存文件
|
YooLogger.Warning($"Failed verify file and delete files : {element.FileRootPath}");
|
||||||
if (Directory.Exists(element.FileRootPath))
|
element.DeleteFiles();
|
||||||
{
|
|
||||||
YooLogger.Warning($"Failed verify file and delete files : {element.FileRootPath}");
|
|
||||||
Directory.Delete(element.FileRootPath, true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -235,7 +231,7 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
private void BeginVerifyFileWithoutThread(VerifyElement element)
|
private void BeginVerifyFileWithoutThread(VerifyElement element)
|
||||||
{
|
{
|
||||||
element.Result = CacheSystem.VerifyingCacheFile(element, CacheSystem.InitVerifyLevel);
|
element.Result = CacheSystem.VerifyingCacheFile(element);
|
||||||
if (element.Result == EVerifyResult.Succeed)
|
if (element.Result == EVerifyResult.Succeed)
|
||||||
{
|
{
|
||||||
_succeedCount++;
|
_succeedCount++;
|
||||||
@@ -246,12 +242,8 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
_failedCount++;
|
_failedCount++;
|
||||||
|
|
||||||
// 删除验证失败的缓存文件
|
YooLogger.Warning($"Failed verify file and delete files : {element.FileRootPath}");
|
||||||
if (Directory.Exists(element.FileRootPath))
|
element.DeleteFiles();
|
||||||
{
|
|
||||||
YooLogger.Warning($"Failed verify file and delete files : {element.FileRootPath}");
|
|
||||||
Directory.Delete(element.FileRootPath, true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
|
using System.IO;
|
||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
internal class VerifyElement
|
internal class VerifyElement
|
||||||
@@ -21,5 +22,18 @@ namespace YooAsset
|
|||||||
DataFilePath = dataFilePath;
|
DataFilePath = dataFilePath;
|
||||||
InfoFilePath = infoFilePath;
|
InfoFilePath = infoFilePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void DeleteFiles()
|
||||||
|
{
|
||||||
|
if (File.Exists(DataFilePath))
|
||||||
|
{
|
||||||
|
File.Delete(DataFilePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (File.Exists(InfoFilePath))
|
||||||
|
{
|
||||||
|
File.Delete(InfoFilePath);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -37,7 +37,7 @@ namespace YooAsset
|
|||||||
// 检测本地临时文件
|
// 检测本地临时文件
|
||||||
if (_steps == ESteps.CheckTempFile)
|
if (_steps == ESteps.CheckTempFile)
|
||||||
{
|
{
|
||||||
var verifyResult = CacheSystem.VerifyingTempFile(_bundleInfo.Bundle, EVerifyLevel.High);
|
var verifyResult = CacheSystem.VerifyingTempFile(_bundleInfo.Bundle);
|
||||||
if (verifyResult == EVerifyResult.Succeed)
|
if (verifyResult == EVerifyResult.Succeed)
|
||||||
{
|
{
|
||||||
_steps = ESteps.CachingFile;
|
_steps = ESteps.CachingFile;
|
||||||
@@ -198,7 +198,7 @@ namespace YooAsset
|
|||||||
// 验证下载文件
|
// 验证下载文件
|
||||||
if (_steps == ESteps.VerifyingFile)
|
if (_steps == ESteps.VerifyingFile)
|
||||||
{
|
{
|
||||||
var verifyResult = CacheSystem.VerifyingTempFile(_bundleInfo.Bundle, EVerifyLevel.High);
|
var verifyResult = CacheSystem.VerifyingTempFile(_bundleInfo.Bundle);
|
||||||
if (verifyResult == EVerifyResult.Succeed)
|
if (verifyResult == EVerifyResult.Succeed)
|
||||||
{
|
{
|
||||||
_steps = ESteps.CachingFile;
|
_steps = ESteps.CachingFile;
|
||||||
|
|||||||
@@ -143,6 +143,7 @@ namespace YooAsset
|
|||||||
patchBundle.IsRawFile = _buffer.ReadBool();
|
patchBundle.IsRawFile = _buffer.ReadBool();
|
||||||
patchBundle.LoadMethod = _buffer.ReadByte();
|
patchBundle.LoadMethod = _buffer.ReadByte();
|
||||||
patchBundle.Tags = _buffer.ReadUTF8Array();
|
patchBundle.Tags = _buffer.ReadUTF8Array();
|
||||||
|
patchBundle.ReferenceIDs = _buffer.ReadInt32Array();
|
||||||
Manifest.BundleList.Add(patchBundle);
|
Manifest.BundleList.Add(patchBundle);
|
||||||
|
|
||||||
patchBundle.ParseBundle(Manifest.PackageName, Manifest.OutputNameStyle);
|
patchBundle.ParseBundle(Manifest.PackageName, Manifest.OutputNameStyle);
|
||||||
|
|||||||
@@ -41,6 +41,11 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string[] Tags;
|
public string[] Tags;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 引用该资源包的ID列表
|
||||||
|
/// </summary>
|
||||||
|
public int[] ReferenceIDs;
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 所属的包裹名称
|
/// 所属的包裹名称
|
||||||
@@ -67,7 +72,7 @@ namespace YooAsset
|
|||||||
return _cachedDataFilePath;
|
return _cachedDataFilePath;
|
||||||
|
|
||||||
string cacheRoot = PersistentHelper.GetCacheFolderPath(PackageName);
|
string cacheRoot = PersistentHelper.GetCacheFolderPath(PackageName);
|
||||||
_cachedDataFilePath = $"{cacheRoot}/{CacheGUID}/{YooAssetSettings.CacheBundleDataFileName}";
|
_cachedDataFilePath = $"{cacheRoot}/{CacheGUID}/{YooAssetSettings.CacheBundleDataFileName}{_fileExtension}";
|
||||||
return _cachedDataFilePath;
|
return _cachedDataFilePath;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -122,7 +127,7 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 文件名称(远端文件名和内置文件名)
|
/// 文件名称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private string _fileName;
|
private string _fileName;
|
||||||
public string FileName
|
public string FileName
|
||||||
@@ -135,6 +140,20 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 文件后缀名
|
||||||
|
/// </summary>
|
||||||
|
private string _fileExtension;
|
||||||
|
public string FileExtension
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(_fileExtension))
|
||||||
|
throw new Exception("Should never get here !");
|
||||||
|
return _fileExtension;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public PatchBundle()
|
public PatchBundle()
|
||||||
{
|
{
|
||||||
@@ -146,7 +165,8 @@ namespace YooAsset
|
|||||||
public void ParseBundle(string packageName, int nameStype)
|
public void ParseBundle(string packageName, int nameStype)
|
||||||
{
|
{
|
||||||
PackageName = packageName;
|
PackageName = packageName;
|
||||||
_fileName = PatchManifestTools.CreateBundleFileName(nameStype, BundleName, FileHash, IsRawFile);
|
_fileExtension = PatchManifestTools.GetRemoteBundleFileExtension(BundleName);
|
||||||
|
_fileName = PatchManifestTools.GetRemoteBundleFileName(nameStype, BundleName, _fileExtension, FileHash);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -220,6 +220,22 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取资源包名称
|
||||||
|
/// </summary>
|
||||||
|
public string GetBundleName(int bundleID)
|
||||||
|
{
|
||||||
|
if (bundleID >= 0 && bundleID < BundleList.Count)
|
||||||
|
{
|
||||||
|
var patchBundle = BundleList[bundleID];
|
||||||
|
return patchBundle.BundleName;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new Exception($"Invalid bundle id : {bundleID}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 尝试获取补丁资源
|
/// 尝试获取补丁资源
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ namespace YooAsset
|
|||||||
buffer.WriteBool(patchBundle.IsRawFile);
|
buffer.WriteBool(patchBundle.IsRawFile);
|
||||||
buffer.WriteByte(patchBundle.LoadMethod);
|
buffer.WriteByte(patchBundle.LoadMethod);
|
||||||
buffer.WriteUTF8Array(patchBundle.Tags);
|
buffer.WriteUTF8Array(patchBundle.Tags);
|
||||||
|
buffer.WriteInt32Array(patchBundle.ReferenceIDs);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 写入文件流
|
// 写入文件流
|
||||||
@@ -127,6 +128,7 @@ namespace YooAsset
|
|||||||
patchBundle.IsRawFile = buffer.ReadBool();
|
patchBundle.IsRawFile = buffer.ReadBool();
|
||||||
patchBundle.LoadMethod = buffer.ReadByte();
|
patchBundle.LoadMethod = buffer.ReadByte();
|
||||||
patchBundle.Tags = buffer.ReadUTF8Array();
|
patchBundle.Tags = buffer.ReadUTF8Array();
|
||||||
|
patchBundle.ReferenceIDs = buffer.ReadInt32Array();
|
||||||
manifest.BundleList.Add(patchBundle);
|
manifest.BundleList.Add(patchBundle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -155,21 +157,21 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/// <summary>
|
public static string GetRemoteBundleFileExtension(string bundleName)
|
||||||
/// 生成Bundle文件的正式名称
|
{
|
||||||
/// </summary>
|
string fileExtension = Path.GetExtension(bundleName);
|
||||||
public static string CreateBundleFileName(int nameStyle, string bundleName, string fileHash, bool isRawFile)
|
return fileExtension;
|
||||||
|
}
|
||||||
|
public static string GetRemoteBundleFileName(int nameStyle, string bundleName, string fileExtension, string fileHash)
|
||||||
{
|
{
|
||||||
if (nameStyle == 1) //HashName
|
if (nameStyle == 1) //HashName
|
||||||
{
|
{
|
||||||
string fileExtension = isRawFile ? YooAssetSettingsData.Setting.RawBundleFileVariant : YooAssetSettingsData.Setting.AssetBundleFileVariant;
|
return StringUtility.Format("{0}{1}", fileHash, fileExtension);
|
||||||
return StringUtility.Format("{0}.{1}", fileHash, fileExtension);
|
|
||||||
}
|
}
|
||||||
else if (nameStyle == 4) //BundleName_HashName
|
else if (nameStyle == 4) //BundleName_HashName
|
||||||
{
|
{
|
||||||
string fileName = bundleName.Remove(bundleName.LastIndexOf('.'));
|
string fileName = bundleName.Remove(bundleName.LastIndexOf('.'));
|
||||||
string fileExtension = isRawFile ? YooAssetSettingsData.Setting.RawBundleFileVariant : YooAssetSettingsData.Setting.AssetBundleFileVariant;
|
return StringUtility.Format("{0}_{1}{2}", fileName, fileHash, fileExtension);
|
||||||
return StringUtility.Format("{0}_{1}.{2}", fileName, fileHash, fileExtension);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -95,6 +95,10 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
string IBundleServices.GetBundleName(int bundleID)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
bool IBundleServices.IsServicesValid()
|
bool IBundleServices.IsServicesValid()
|
||||||
{
|
{
|
||||||
return _activeManifest != null;
|
return _activeManifest != null;
|
||||||
|
|||||||
@@ -330,6 +330,10 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
return result.ToArray();
|
return result.ToArray();
|
||||||
}
|
}
|
||||||
|
string IBundleServices.GetBundleName(int bundleID)
|
||||||
|
{
|
||||||
|
return _activeManifest.GetBundleName(bundleID);
|
||||||
|
}
|
||||||
bool IBundleServices.IsServicesValid()
|
bool IBundleServices.IsServicesValid()
|
||||||
{
|
{
|
||||||
return _activeManifest != null;
|
return _activeManifest != null;
|
||||||
|
|||||||
@@ -123,6 +123,10 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
return result.ToArray();
|
return result.ToArray();
|
||||||
}
|
}
|
||||||
|
string IBundleServices.GetBundleName(int bundleID)
|
||||||
|
{
|
||||||
|
return _activeManifest.GetBundleName(bundleID);
|
||||||
|
}
|
||||||
bool IBundleServices.IsServicesValid()
|
bool IBundleServices.IsServicesValid()
|
||||||
{
|
{
|
||||||
return _activeManifest != null;
|
return _activeManifest != null;
|
||||||
|
|||||||
@@ -13,6 +13,11 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
BundleInfo[] GetAllDependBundleInfos(AssetInfo assetPath);
|
BundleInfo[] GetAllDependBundleInfos(AssetInfo assetPath);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取资源包名称
|
||||||
|
/// </summary>
|
||||||
|
string GetBundleName(int bundleID);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 服务接口是否有效
|
/// 服务接口是否有效
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -5,26 +5,11 @@ namespace YooAsset
|
|||||||
[CreateAssetMenu(fileName = "YooAssetSettings", menuName = "YooAsset/Create Settings")]
|
[CreateAssetMenu(fileName = "YooAssetSettings", menuName = "YooAsset/Create Settings")]
|
||||||
internal class YooAssetSettings : ScriptableObject
|
internal class YooAssetSettings : ScriptableObject
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// AssetBundle文件的后缀名
|
|
||||||
/// </summary>
|
|
||||||
public string AssetBundleFileVariant = "bundle";
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 原生文件的后缀名
|
|
||||||
/// </summary>
|
|
||||||
public string RawBundleFileVariant = "rawfile";
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 清单文件名称
|
/// 清单文件名称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string PatchManifestFileName = "PatchManifest";
|
public string PatchManifestFileName = "PatchManifest";
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 资源包名正规化(移除路径分隔符)
|
|
||||||
/// </summary>
|
|
||||||
public bool RegularBundleName = true;
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 清单文件头标记
|
/// 清单文件头标记
|
||||||
@@ -39,7 +24,7 @@ namespace YooAsset
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 清单文件格式版本
|
/// 清单文件格式版本
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const string PatchManifestFileVersion = "1.4.0";
|
public const string PatchManifestFileVersion = "1.4.6";
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -63,20 +48,9 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public const string ReportFileName = "BuildReport";
|
public const string ReportFileName = "BuildReport";
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Unity着色器资源包名称
|
|
||||||
/// </summary>
|
|
||||||
public const string UnityShadersBundleName = "unityshaders";
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 内置资源目录名称
|
/// 内置资源目录名称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const string StreamingAssetsBuildinFolder = "BuildinFiles";
|
public const string StreamingAssetsBuildinFolder = "BuildinFiles";
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 忽略的文件类型
|
|
||||||
/// </summary>
|
|
||||||
public static readonly string[] IgnoreFileExtensions = { "", ".so", ".dll", ".cs", ".js", ".boo", ".meta", ".cginc", ".hlsl" };
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -71,18 +71,5 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
return $"{Setting.PatchManifestFileName}_{packageName}.version";
|
return $"{Setting.PatchManifestFileName}_{packageName}.version";
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 获取着色器资源包全名称(包含后缀名)
|
|
||||||
/// </summary>
|
|
||||||
public static string GetUnityShadersBundleFullName(bool uniqueBundleName, string packageName)
|
|
||||||
{
|
|
||||||
string shareBundleName;
|
|
||||||
if (uniqueBundleName)
|
|
||||||
shareBundleName = $"{packageName.ToLower()}_{YooAssetSettings.UnityShadersBundleName}.{Setting.AssetBundleFileVariant}";
|
|
||||||
else
|
|
||||||
shareBundleName = $"{YooAssetSettings.UnityShadersBundleName}.{Setting.AssetBundleFileVariant}";
|
|
||||||
return shareBundleName.ToLower();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -10,7 +10,7 @@ public class PackEffectTexture : IPackRule
|
|||||||
{
|
{
|
||||||
private const string PackDirectory = "Assets/Effect/Textures/";
|
private const string PackDirectory = "Assets/Effect/Textures/";
|
||||||
|
|
||||||
string IPackRule.GetBundleName(PackRuleData data)
|
PackRuleResult IPackRule.GetPackRuleResult(PackRuleData data)
|
||||||
{
|
{
|
||||||
string assetPath = data.AssetPath;
|
string assetPath = data.AssetPath;
|
||||||
if (assetPath.StartsWith(PackDirectory) == false)
|
if (assetPath.StartsWith(PackDirectory) == false)
|
||||||
@@ -18,6 +18,43 @@ public class PackEffectTexture : IPackRule
|
|||||||
|
|
||||||
string assetName = Path.GetFileName(assetPath).ToLower();
|
string assetName = Path.GetFileName(assetPath).ToLower();
|
||||||
string firstChar = assetName.Substring(0, 1);
|
string firstChar = assetName.Substring(0, 1);
|
||||||
return $"{PackDirectory}effect_texture_{firstChar}";
|
string bundleName = $"{PackDirectory}effect_texture_{firstChar}";
|
||||||
|
var packRuleResult = new PackRuleResult(bundleName, DefaultPackRule.AssetBundleFileExtension);
|
||||||
|
return packRuleResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IPackRule.IsRawFilePackRule()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[DisplayName("打包视频(自定义)")]
|
||||||
|
public class PackVideo : IPackRule
|
||||||
|
{
|
||||||
|
public PackRuleResult GetPackRuleResult(PackRuleData data)
|
||||||
|
{
|
||||||
|
string bundleName = RemoveExtension(data.AssetPath);
|
||||||
|
string fileExtension = Path.GetExtension(data.AssetPath);
|
||||||
|
fileExtension = fileExtension.Remove(0, 1);
|
||||||
|
PackRuleResult result = new PackRuleResult(bundleName, fileExtension);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IPackRule.IsRawFilePackRule()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private string RemoveExtension(string str)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(str))
|
||||||
|
return str;
|
||||||
|
|
||||||
|
int index = str.LastIndexOf(".");
|
||||||
|
if (index == -1)
|
||||||
|
return str;
|
||||||
|
else
|
||||||
|
return str.Remove(index); //"assets/config/test.unity3d" --> "assets/config/test"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,22 +1,22 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<root Version="2.2">
|
<root Version="2.3">
|
||||||
<Common AutoAddressable="True" UniqueBundleName="False" ShowPackageView="False" ShowEditorAlias="False" />
|
<Common AutoAddressable="True" UniqueBundleName="False" ShowPackageView="False" ShowEditorAlias="False" />
|
||||||
<Package PackageName="DefaultPackage" PackageDesc="">
|
<Package PackageName="DefaultPackage" PackageDesc="">
|
||||||
<Group GroupName="battle" GroupDesc="" AssetTags="">
|
<Group GroupName="battle" GroupDesc="" AssetTags="">
|
||||||
<Collector CollectPath="Assets/Samples/Space Shooter/GameRes/Effect" CollectGUID="80d76514758554baaa96a9efffe9f3ef" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackDirectory" FilterRule="CollectAll" AssetTags="" />
|
<Collector CollectPath="Assets/Samples/Space Shooter/GameRes/Effect" CollectGUID="80d76514758554baaa96a9efffe9f3ef" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackDirectory" FilterRule="CollectAll" UserData="" AssetTags="" />
|
||||||
<Collector CollectPath="Assets/Samples/Space Shooter/GameRes/Entity" CollectGUID="4d7c84745db8e884f8020a8c5356e67c" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackDirectory" FilterRule="CollectAll" AssetTags="" />
|
<Collector CollectPath="Assets/Samples/Space Shooter/GameRes/Entity" CollectGUID="4d7c84745db8e884f8020a8c5356e67c" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackDirectory" FilterRule="CollectAll" UserData="" AssetTags="" />
|
||||||
<Collector CollectPath="Assets/Samples/Space Shooter/GameRes/Audio" CollectGUID="306075fbe00b24251b6c889984a7a7d5" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackDirectory" FilterRule="CollectAll" AssetTags="" />
|
<Collector CollectPath="Assets/Samples/Space Shooter/GameRes/Audio" CollectGUID="306075fbe00b24251b6c889984a7a7d5" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackDirectory" FilterRule="CollectAll" UserData="" AssetTags="" />
|
||||||
</Group>
|
</Group>
|
||||||
<Group GroupName="shader" GroupDesc="" AssetTags="">
|
<Group GroupName="shader" GroupDesc="" AssetTags="">
|
||||||
<Collector CollectPath="Assets/Samples/Space Shooter/GameArt/ShaderVariants" CollectGUID="00781758c26692e40a9634ddeac838be" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackShaderVariants" FilterRule="CollectShaderVariants" AssetTags="" />
|
<Collector CollectPath="Assets/Samples/Space Shooter/GameArt/ShaderVariants" CollectGUID="00781758c26692e40a9634ddeac838be" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackShaderVariants" FilterRule="CollectShaderVariants" UserData="" AssetTags="" />
|
||||||
</Group>
|
</Group>
|
||||||
<Group GroupName="scene" GroupDesc="" AssetTags="">
|
<Group GroupName="scene" GroupDesc="" AssetTags="">
|
||||||
<Collector CollectPath="Assets/Samples/Space Shooter/GameRes/Scene" CollectGUID="6070eae1192f2994887f2983a177d503" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackSeparately" FilterRule="CollectAll" AssetTags="" />
|
<Collector CollectPath="Assets/Samples/Space Shooter/GameRes/Scene" CollectGUID="6070eae1192f2994887f2983a177d503" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackSeparately" FilterRule="CollectAll" UserData="" AssetTags="" />
|
||||||
</Group>
|
</Group>
|
||||||
<Group GroupName="ugui" GroupDesc="" AssetTags="">
|
<Group GroupName="ugui" GroupDesc="" AssetTags="">
|
||||||
<Collector CollectPath="Assets/Samples/Space Shooter/GameRes/UIImage" CollectGUID="30c57db62bb02a24590e7046d3a9e33a" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackDirectory" FilterRule="CollectAll" AssetTags="" />
|
<Collector CollectPath="Assets/Samples/Space Shooter/GameRes/UIImage" CollectGUID="30c57db62bb02a24590e7046d3a9e33a" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackDirectory" FilterRule="CollectAll" UserData="" AssetTags="" />
|
||||||
<Collector CollectPath="Assets/Samples/Space Shooter/GameRes/UIPanel" CollectGUID="12d33f33f3a55224c9c747d7bffa1c68" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackSeparately" FilterRule="CollectAll" AssetTags="" />
|
<Collector CollectPath="Assets/Samples/Space Shooter/GameRes/UIPanel" CollectGUID="12d33f33f3a55224c9c747d7bffa1c68" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackSeparately" FilterRule="CollectAll" UserData="" AssetTags="" />
|
||||||
<Collector CollectPath="Assets/Samples/Space Shooter/GameRes/UISprite" CollectGUID="01865ad6f7c806147b6cb37f2d83bc96" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackTopDirectory" FilterRule="CollectAll" AssetTags="" />
|
<Collector CollectPath="Assets/Samples/Space Shooter/GameRes/UISprite" CollectGUID="01865ad6f7c806147b6cb37f2d83bc96" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackTopDirectory" FilterRule="CollectAll" UserData="" AssetTags="" />
|
||||||
</Group>
|
</Group>
|
||||||
</Package>
|
</Package>
|
||||||
</root>
|
</root>
|
||||||
@@ -32,6 +32,7 @@ MonoBehaviour:
|
|||||||
PackRuleName: PackDirectory
|
PackRuleName: PackDirectory
|
||||||
FilterRuleName: CollectAll
|
FilterRuleName: CollectAll
|
||||||
AssetTags:
|
AssetTags:
|
||||||
|
UserData:
|
||||||
- CollectPath: Assets/Samples/Space Shooter/GameRes/Entity
|
- CollectPath: Assets/Samples/Space Shooter/GameRes/Entity
|
||||||
CollectorGUID: 4d7c84745db8e884f8020a8c5356e67c
|
CollectorGUID: 4d7c84745db8e884f8020a8c5356e67c
|
||||||
CollectorType: 0
|
CollectorType: 0
|
||||||
@@ -39,6 +40,7 @@ MonoBehaviour:
|
|||||||
PackRuleName: PackDirectory
|
PackRuleName: PackDirectory
|
||||||
FilterRuleName: CollectAll
|
FilterRuleName: CollectAll
|
||||||
AssetTags:
|
AssetTags:
|
||||||
|
UserData:
|
||||||
- CollectPath: Assets/Samples/Space Shooter/GameRes/Audio
|
- CollectPath: Assets/Samples/Space Shooter/GameRes/Audio
|
||||||
CollectorGUID: 306075fbe00b24251b6c889984a7a7d5
|
CollectorGUID: 306075fbe00b24251b6c889984a7a7d5
|
||||||
CollectorType: 0
|
CollectorType: 0
|
||||||
@@ -46,6 +48,7 @@ MonoBehaviour:
|
|||||||
PackRuleName: PackDirectory
|
PackRuleName: PackDirectory
|
||||||
FilterRuleName: CollectAll
|
FilterRuleName: CollectAll
|
||||||
AssetTags:
|
AssetTags:
|
||||||
|
UserData:
|
||||||
- GroupName: shader
|
- GroupName: shader
|
||||||
GroupDesc:
|
GroupDesc:
|
||||||
AssetTags:
|
AssetTags:
|
||||||
@@ -58,6 +61,7 @@ MonoBehaviour:
|
|||||||
PackRuleName: PackShaderVariants
|
PackRuleName: PackShaderVariants
|
||||||
FilterRuleName: CollectShaderVariants
|
FilterRuleName: CollectShaderVariants
|
||||||
AssetTags:
|
AssetTags:
|
||||||
|
UserData:
|
||||||
- GroupName: scene
|
- GroupName: scene
|
||||||
GroupDesc:
|
GroupDesc:
|
||||||
AssetTags:
|
AssetTags:
|
||||||
@@ -70,6 +74,7 @@ MonoBehaviour:
|
|||||||
PackRuleName: PackSeparately
|
PackRuleName: PackSeparately
|
||||||
FilterRuleName: CollectAll
|
FilterRuleName: CollectAll
|
||||||
AssetTags:
|
AssetTags:
|
||||||
|
UserData:
|
||||||
- GroupName: ugui
|
- GroupName: ugui
|
||||||
GroupDesc:
|
GroupDesc:
|
||||||
AssetTags:
|
AssetTags:
|
||||||
@@ -82,6 +87,7 @@ MonoBehaviour:
|
|||||||
PackRuleName: PackDirectory
|
PackRuleName: PackDirectory
|
||||||
FilterRuleName: CollectAll
|
FilterRuleName: CollectAll
|
||||||
AssetTags:
|
AssetTags:
|
||||||
|
UserData:
|
||||||
- CollectPath: Assets/Samples/Space Shooter/GameRes/UIPanel
|
- CollectPath: Assets/Samples/Space Shooter/GameRes/UIPanel
|
||||||
CollectorGUID: 12d33f33f3a55224c9c747d7bffa1c68
|
CollectorGUID: 12d33f33f3a55224c9c747d7bffa1c68
|
||||||
CollectorType: 0
|
CollectorType: 0
|
||||||
@@ -89,6 +95,7 @@ MonoBehaviour:
|
|||||||
PackRuleName: PackSeparately
|
PackRuleName: PackSeparately
|
||||||
FilterRuleName: CollectAll
|
FilterRuleName: CollectAll
|
||||||
AssetTags:
|
AssetTags:
|
||||||
|
UserData:
|
||||||
- CollectPath: Assets/Samples/Space Shooter/GameRes/UISprite
|
- CollectPath: Assets/Samples/Space Shooter/GameRes/UISprite
|
||||||
CollectorGUID: 01865ad6f7c806147b6cb37f2d83bc96
|
CollectorGUID: 01865ad6f7c806147b6cb37f2d83bc96
|
||||||
CollectorType: 0
|
CollectorType: 0
|
||||||
@@ -96,3 +103,4 @@ MonoBehaviour:
|
|||||||
PackRuleName: PackTopDirectory
|
PackRuleName: PackTopDirectory
|
||||||
FilterRuleName: CollectAll
|
FilterRuleName: CollectAll
|
||||||
AssetTags:
|
AssetTags:
|
||||||
|
UserData:
|
||||||
|
|||||||
@@ -42,7 +42,8 @@ public class FileStreamEncryption : IEncryptionServices
|
|||||||
{
|
{
|
||||||
public EncryptResult Encrypt(EncryptFileInfo fileInfo)
|
public EncryptResult Encrypt(EncryptFileInfo fileInfo)
|
||||||
{
|
{
|
||||||
if (fileInfo.BundleName.Contains("gameres_music"))
|
// LoadFromStream
|
||||||
|
if (fileInfo.BundleName.Contains("_gameres_audio"))
|
||||||
{
|
{
|
||||||
var fileData = File.ReadAllBytes(fileInfo.FilePath);
|
var fileData = File.ReadAllBytes(fileInfo.FilePath);
|
||||||
for (int i = 0; i < fileData.Length; i++)
|
for (int i = 0; i < fileData.Length; i++)
|
||||||
@@ -55,7 +56,22 @@ public class FileStreamEncryption : IEncryptionServices
|
|||||||
result.EncryptedData = fileData;
|
result.EncryptedData = fileData;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
// LoadFromFileOffset
|
||||||
|
if (fileInfo.BundleName.Contains("_gameres_uiimage"))
|
||||||
|
{
|
||||||
|
var fileData = File.ReadAllBytes(fileInfo.FilePath);
|
||||||
|
int offset = 32;
|
||||||
|
var temper = new byte[fileData.Length + offset];
|
||||||
|
Buffer.BlockCopy(fileData, 0, temper, offset, fileData.Length);
|
||||||
|
|
||||||
|
EncryptResult result = new EncryptResult();
|
||||||
|
result.LoadMethod = EBundleLoadMethod.LoadFromFileOffset;
|
||||||
|
result.EncryptedData = temper;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Normal
|
||||||
{
|
{
|
||||||
EncryptResult result = new EncryptResult();
|
EncryptResult result = new EncryptResult();
|
||||||
result.LoadMethod = EBundleLoadMethod.Normal;
|
result.LoadMethod = EBundleLoadMethod.Normal;
|
||||||
|
|||||||
@@ -13,27 +13,51 @@ internal class AndroidPost : UnityEditor.Android.IPostGenerateGradleAndroidProje
|
|||||||
path = path.Replace("\\", "/");
|
path = path.Replace("\\", "/");
|
||||||
string untityActivityFilePath = $"{path}/src/main/java/com/unity3d/player/UnityPlayerActivity.java";
|
string untityActivityFilePath = $"{path}/src/main/java/com/unity3d/player/UnityPlayerActivity.java";
|
||||||
var readContent = System.IO.File.ReadAllLines(untityActivityFilePath);
|
var readContent = System.IO.File.ReadAllLines(untityActivityFilePath);
|
||||||
string postContent = " //auto-gen-function\n" +
|
string postContent =
|
||||||
" public boolean CheckAssetExist(String filePath){\n" +
|
" //auto-gen-function \n" +
|
||||||
" android.content.res.AssetManager assetManager = getAssets();\n" +
|
" public boolean CheckAssetExist(String filePath) \n" +
|
||||||
" java.io.InputStream inputStream = null;\n" +
|
" { \n" +
|
||||||
" try {\n" +
|
" android.content.res.AssetManager assetManager = getAssets(); \n" +
|
||||||
" inputStream = assetManager.open(filePath);\n" +
|
" try \n" +
|
||||||
" if(null != inputStream)return true;\n" +
|
" { \n" +
|
||||||
" }catch(java.io.IOException e) {\n" +
|
" java.io.InputStream inputStream = assetManager.open(filePath); \n" +
|
||||||
" e.printStackTrace();\n" +
|
" if (null != inputStream) \n" +
|
||||||
" }finally{\n" +
|
" { \n" +
|
||||||
" try {\n" +
|
" inputStream.close(); \n" +
|
||||||
" inputStream.close();\n" +
|
" return true; \n" +
|
||||||
" } catch (java.io.IOException e) {\n" +
|
" } \n" +
|
||||||
" e.printStackTrace();\n" +
|
" } \n" +
|
||||||
" }\n" +
|
" catch(java.io.IOException e) \n" +
|
||||||
" }\n" +
|
" { \n" +
|
||||||
" return false;\n" +
|
" e.printStackTrace(); \n" +
|
||||||
" }\n" +
|
" } \n" +
|
||||||
|
" return false; \n" +
|
||||||
|
" } \n" +
|
||||||
"}";
|
"}";
|
||||||
if (!readContent[readContent.Length - 18].Contains("CheckAssetExist"))
|
if (!readContent[readContent.Length - 18].Contains("CheckAssetExist"))
|
||||||
readContent[readContent.Length - 1] = postContent;
|
readContent[readContent.Length - 1] = postContent;
|
||||||
System.IO.File.WriteAllLines(untityActivityFilePath, readContent);
|
System.IO.File.WriteAllLines(untityActivityFilePath, readContent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
//auto-gen-function
|
||||||
|
public boolean CheckAssetExist(String filePath)
|
||||||
|
{
|
||||||
|
android.content.res.AssetManager assetManager = getAssets();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
java.io.InputStream inputStream = assetManager.open(filePath);
|
||||||
|
if(null != inputStream)
|
||||||
|
{
|
||||||
|
inputStream.close();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch(java.io.IOException e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
*/
|
||||||
@@ -1,10 +1,13 @@
|
|||||||
//-------------------------------------
|
//-------------------------------------
|
||||||
// 作者:Stark
|
// 作者:Stark
|
||||||
//-------------------------------------
|
//-------------------------------------
|
||||||
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
public sealed class StreamingAssetsHelper
|
public sealed class StreamingAssetsHelper
|
||||||
{
|
{
|
||||||
|
private static readonly Dictionary<string, bool> _cacheData = new Dictionary<string, bool>(1000);
|
||||||
|
|
||||||
#if UNITY_ANDROID && !UNITY_EDITOR
|
#if UNITY_ANDROID && !UNITY_EDITOR
|
||||||
private static AndroidJavaClass _unityPlayerClass;
|
private static AndroidJavaClass _unityPlayerClass;
|
||||||
public static AndroidJavaClass UnityPlayerClass
|
public static AndroidJavaClass UnityPlayerClass
|
||||||
@@ -33,12 +36,22 @@ public sealed class StreamingAssetsHelper
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static bool FileExists(string filePath)
|
public static bool FileExists(string filePath)
|
||||||
{
|
{
|
||||||
return CurrentActivity.Call<bool>("CheckAssetExist", filePath);
|
if (_cacheData.TryGetValue(filePath, out bool result) == false)
|
||||||
|
{
|
||||||
|
result = CurrentActivity.Call<bool>("CheckAssetExist", filePath);
|
||||||
|
_cacheData.Add(filePath, result);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
public static bool FileExists(string filePath)
|
public static bool FileExists(string filePath)
|
||||||
{
|
{
|
||||||
return System.IO.File.Exists(System.IO.Path.Combine(Application.streamingAssetsPath, filePath));
|
if (_cacheData.TryGetValue(filePath, out bool result) == false)
|
||||||
|
{
|
||||||
|
result = System.IO.File.Exists(System.IO.Path.Combine(Application.streamingAssetsPath, filePath));
|
||||||
|
_cacheData.Add(filePath, result);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "com.tuyoogame.yooasset",
|
"name": "com.tuyoogame.yooasset",
|
||||||
"displayName": "YooAsset",
|
"displayName": "YooAsset",
|
||||||
"version": "1.4.3-preview",
|
"version": "1.4.6-preview",
|
||||||
"unity": "2019.4",
|
"unity": "2019.4",
|
||||||
"description": "unity3d resources management system.",
|
"description": "unity3d resources management system.",
|
||||||
"author": {
|
"author": {
|
||||||
|
|||||||
@@ -20,3 +20,6 @@ CDN
|
|||||||
└─v2.0
|
└─v2.0
|
||||||
````
|
````
|
||||||
|
|
||||||
|
**游戏版本说明**
|
||||||
|
|
||||||
|
v1.0 代表的是游戏版本,不是资源版本。在没有更换安装包的前提下,不需要递增这个游戏版本。每次生成的补丁包只需要覆盖掉当前游戏版本目录下即可。
|
||||||
|
|||||||
BIN
Docs/Image/Samples-img3.jpg
Normal file
BIN
Docs/Image/Samples-img3.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 28 KiB |
@@ -17,3 +17,9 @@
|
|||||||
1. Space Shooter在导入完成后,打开YooAsset->AssetBundle Collector窗口。
|
1. Space Shooter在导入完成后,打开YooAsset->AssetBundle Collector窗口。
|
||||||
1. 点击修复按钮,然后点击Save按钮保存配置,最后关闭窗口。
|
1. 点击修复按钮,然后点击Save按钮保存配置,最后关闭窗口。
|
||||||
3. 找到Boot.scene场景启动游戏。
|
3. 找到Boot.scene场景启动游戏。
|
||||||
|
|
||||||
|
#### 太空战机项目
|
||||||
|
|
||||||
|
首次需要在项目里手动添加Tags才可以保证真机演示正常运行。
|
||||||
|
|
||||||
|

|
||||||
|
|||||||
@@ -4,6 +4,8 @@
|
|||||||
|
|
||||||
点击搜集变种按钮开始收集,请耐心等待结束。
|
点击搜集变种按钮开始收集,请耐心等待结束。
|
||||||
|
|
||||||
|
**注意:在收集完成之后,需要将生成的shadervariants文件配置到收集界面(AssetBundle Collector)。**
|
||||||
|
|
||||||
### Jenkins支持
|
### Jenkins支持
|
||||||
|
|
||||||
```c#
|
```c#
|
||||||
|
|||||||
Reference in New Issue
Block a user