Compare commits

..

No commits in common. "697a87721f19cac933e7994afd584ffc744c11f4" and "a618b6cf9e14c707aa3f3bbd697004b4583e5cf6" have entirely different histories.

11 changed files with 60 additions and 109 deletions

View File

@ -2,41 +2,6 @@
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.5.4-preview] - 2023-08-25
优化了资源清单文件构建速度极大提升构建体验感谢yingnierxiao同学
### Fixed
- (#130) 修复了打包路径无效问题bug
- (#138) 修复了Unity不支持的格式的原生文件会报warning
### Added
- 新增了IBuildinQueryServices 接口。
### Changed
- 在开启可寻址模式下,默认支持通过资源路径加载资源对象。
- 优化了资源收集界面,增加了配置相关的警示提示。
- 优化了资源报告界面增加了BundleView界面里的builtin资源的列表显示。
- IQueryServices接口变更为IBuildinQueryServices接口
- EOperationStatus增加了正在处理的状态。
```c#
public enum EOperationStatus
{
None,
Processing,
Succeed,
Failed
}
```
## [1.5.3-preview] - 2023-07-28 ## [1.5.3-preview] - 2023-07-28
### Fixed ### Fixed

View File

@ -40,12 +40,7 @@ namespace YooAsset.Editor
manifest.OutputNameStyle = (int)buildParameters.OutputNameStyle; manifest.OutputNameStyle = (int)buildParameters.OutputNameStyle;
manifest.PackageName = buildParameters.PackageName; manifest.PackageName = buildParameters.PackageName;
manifest.PackageVersion = buildParameters.PackageVersion; manifest.PackageVersion = buildParameters.PackageVersion;
// 填充资源包集合
manifest.BundleList = GetAllPackageBundle(context); manifest.BundleList = GetAllPackageBundle(context);
CacheBundleIDs(manifest);
// 填充主资源集合
manifest.AssetList = GetAllPackageAsset(context, manifest); manifest.AssetList = GetAllPackageAsset(context, manifest);
// 更新Unity内置资源包的引用关系 // 更新Unity内置资源包的引用关系
@ -152,7 +147,7 @@ namespace YooAsset.Editor
packageAsset.AssetPath = assetInfo.AssetPath; packageAsset.AssetPath = assetInfo.AssetPath;
packageAsset.AssetGUID = buildMapContext.Command.IncludeAssetGUID ? assetInfo.AssetGUID : string.Empty; packageAsset.AssetGUID = buildMapContext.Command.IncludeAssetGUID ? assetInfo.AssetGUID : string.Empty;
packageAsset.AssetTags = assetInfo.AssetTags.ToArray(); packageAsset.AssetTags = assetInfo.AssetTags.ToArray();
packageAsset.BundleID = GetCachedBundleID(assetInfo.BundleName); packageAsset.BundleID = GetAssetBundleID(assetInfo.BundleName, manifest);
packageAsset.DependIDs = GetAssetBundleDependIDs(packageAsset.BundleID, assetInfo, manifest); packageAsset.DependIDs = GetAssetBundleDependIDs(packageAsset.BundleID, assetInfo, manifest);
result.Add(packageAsset); result.Add(packageAsset);
} }
@ -161,12 +156,12 @@ namespace YooAsset.Editor
} }
private int[] GetAssetBundleDependIDs(int mainBundleID, BuildAssetInfo assetInfo, PackageManifest manifest) private int[] GetAssetBundleDependIDs(int mainBundleID, BuildAssetInfo assetInfo, PackageManifest manifest)
{ {
HashSet<int> result = new HashSet<int>(); List<int> result = new List<int>();
foreach (var dependAssetInfo in assetInfo.AllDependAssetInfos) foreach (var dependAssetInfo in assetInfo.AllDependAssetInfos)
{ {
if (dependAssetInfo.HasBundleName()) if (dependAssetInfo.HasBundleName())
{ {
int bundleID = GetCachedBundleID(dependAssetInfo.BundleName); int bundleID = GetAssetBundleID(dependAssetInfo.BundleName, manifest);
if (mainBundleID != bundleID) if (mainBundleID != bundleID)
{ {
if (result.Contains(bundleID) == false) if (result.Contains(bundleID) == false)
@ -176,6 +171,15 @@ namespace YooAsset.Editor
} }
return result.ToArray(); return result.ToArray();
} }
private int GetAssetBundleID(string bundleName, PackageManifest manifest)
{
for (int index = 0; index < manifest.BundleList.Count; index++)
{
if (manifest.BundleList[index].BundleName == bundleName)
return index;
}
throw new Exception($"Not found bundle name : {bundleName}");
}
/// <summary> /// <summary>
/// 更新Unity内置资源包的引用关系 /// 更新Unity内置资源包的引用关系
@ -208,7 +212,7 @@ namespace YooAsset.Editor
List<string> conflictAssetPathList = dependBundles.Intersect(shaderBundleReferenceList).ToList(); List<string> conflictAssetPathList = dependBundles.Intersect(shaderBundleReferenceList).ToList();
if (conflictAssetPathList.Count > 0) if (conflictAssetPathList.Count > 0)
{ {
HashSet<int> newDependIDs = new HashSet<int>(packageAsset.DependIDs); List<int> newDependIDs = new List<int>(packageAsset.DependIDs);
if (newDependIDs.Contains(shaderBundleId) == false) if (newDependIDs.Contains(shaderBundleId) == false)
newDependIDs.Add(shaderBundleId); newDependIDs.Add(shaderBundleId);
packageAsset.DependIDs = newDependIDs.ToArray(); packageAsset.DependIDs = newDependIDs.ToArray();
@ -222,7 +226,7 @@ namespace YooAsset.Editor
// 更新资源包标签 // 更新资源包标签
var packageBundle = manifest.BundleList[shaderBundleId]; var packageBundle = manifest.BundleList[shaderBundleId];
HashSet<string> newTags = new HashSet<string>(packageBundle.Tags); List<string> newTags = new List<string>(packageBundle.Tags);
foreach (var tag in tagTemps) foreach (var tag in tagTemps)
{ {
if (newTags.Contains(tag) == false) if (newTags.Contains(tag) == false)
@ -246,22 +250,23 @@ namespace YooAsset.Editor
#region 资源包引用关系相关 #region 资源包引用关系相关
private readonly Dictionary<string, int> _cachedBundleID = new Dictionary<string, int>(10000); private readonly Dictionary<string, int> _cachedBundleID = new Dictionary<string, int>(10000);
private readonly Dictionary<string, string[]> _cachedBundleDepends = new Dictionary<string, string[]>(10000); private readonly Dictionary<string, string[]> _cachedBundleDepends = new Dictionary<string, string[]>(10000);
private void CacheBundleIDs(PackageManifest manifest)
{
UnityEngine.Debug.Assert(manifest.BundleList.Count != 0, "Manifest bundle list is empty !");
for (int index = 0; index < manifest.BundleList.Count; index++)
{
string bundleName = manifest.BundleList[index].BundleName;
_cachedBundleID.Add(bundleName, index);
}
}
private void UpdateScriptPipelineReference(PackageManifest manifest, TaskBuilding_SBP.BuildResultContext buildResultContext) private void UpdateScriptPipelineReference(PackageManifest manifest, TaskBuilding_SBP.BuildResultContext buildResultContext)
{ {
int progressValue; int progressValue;
int totalCount = manifest.BundleList.Count; int totalCount = manifest.BundleList.Count;
// 缓存资源包ID
_cachedBundleID.Clear();
progressValue = 0;
foreach (var packageBundle in manifest.BundleList)
{
int bundleID = GetAssetBundleID(packageBundle.BundleName, manifest);
_cachedBundleID.Add(packageBundle.BundleName, bundleID);
EditorTools.DisplayProgressBar("缓存资源包索引", ++progressValue, totalCount);
}
EditorTools.ClearProgressBar();
// 缓存资源包依赖 // 缓存资源包依赖
_cachedBundleDepends.Clear(); _cachedBundleDepends.Clear();
progressValue = 0; progressValue = 0;
@ -278,11 +283,7 @@ namespace YooAsset.Editor
var depends = buildResultContext.Results.BundleInfos[packageBundle.BundleName].Dependencies; var depends = buildResultContext.Results.BundleInfos[packageBundle.BundleName].Dependencies;
_cachedBundleDepends.Add(packageBundle.BundleName, depends); _cachedBundleDepends.Add(packageBundle.BundleName, depends);
int pro = ++progressValue; EditorTools.DisplayProgressBar("缓存资源包依赖列表", ++progressValue, totalCount);
if (pro % 100 == 0)
{
EditorTools.DisplayProgressBar("缓存资源包依赖列表", pro, totalCount);
}
} }
EditorTools.ClearProgressBar(); EditorTools.ClearProgressBar();
@ -290,11 +291,7 @@ namespace YooAsset.Editor
foreach (var packageBundle in manifest.BundleList) foreach (var packageBundle in manifest.BundleList)
{ {
packageBundle.ReferenceIDs = GetBundleRefrenceIDs(manifest, packageBundle); packageBundle.ReferenceIDs = GetBundleRefrenceIDs(manifest, packageBundle);
int pro = ++progressValue; EditorTools.DisplayProgressBar("计算资源包引用关系", ++progressValue, totalCount);
if (pro % 100 == 0)
{
EditorTools.DisplayProgressBar("计算资源包引用关系", pro, totalCount);
}
} }
EditorTools.ClearProgressBar(); EditorTools.ClearProgressBar();
} }
@ -303,6 +300,17 @@ namespace YooAsset.Editor
int progressValue; int progressValue;
int totalCount = manifest.BundleList.Count; int totalCount = manifest.BundleList.Count;
// 缓存资源包ID
_cachedBundleID.Clear();
progressValue = 0;
foreach (var packageBundle in manifest.BundleList)
{
int bundleID = GetAssetBundleID(packageBundle.BundleName, manifest);
_cachedBundleID.Add(packageBundle.BundleName, bundleID);
EditorTools.DisplayProgressBar("缓存资源包索引", ++progressValue, totalCount);
}
EditorTools.ClearProgressBar();
// 缓存资源包依赖 // 缓存资源包依赖
_cachedBundleDepends.Clear(); _cachedBundleDepends.Clear();
progressValue = 0; progressValue = 0;
@ -316,11 +324,7 @@ namespace YooAsset.Editor
var depends = buildResultContext.UnityManifest.GetDirectDependencies(packageBundle.BundleName); var depends = buildResultContext.UnityManifest.GetDirectDependencies(packageBundle.BundleName);
_cachedBundleDepends.Add(packageBundle.BundleName, depends); _cachedBundleDepends.Add(packageBundle.BundleName, depends);
int pro = ++progressValue; EditorTools.DisplayProgressBar("缓存资源包依赖列表", ++progressValue, totalCount);
if (pro % 100 == 0)
{
EditorTools.DisplayProgressBar("缓存资源包依赖列表", pro, totalCount);
}
} }
EditorTools.ClearProgressBar(); EditorTools.ClearProgressBar();
@ -329,11 +333,7 @@ namespace YooAsset.Editor
foreach (var packageBundle in manifest.BundleList) foreach (var packageBundle in manifest.BundleList)
{ {
packageBundle.ReferenceIDs = GetBundleRefrenceIDs(manifest, packageBundle); packageBundle.ReferenceIDs = GetBundleRefrenceIDs(manifest, packageBundle);
int pro = ++progressValue; EditorTools.DisplayProgressBar("计算资源包引用关系", ++progressValue, totalCount);
if (pro % 100 == 0)
{
EditorTools.DisplayProgressBar("计算资源包引用关系", ++progressValue, totalCount);
}
} }
EditorTools.ClearProgressBar(); EditorTools.ClearProgressBar();
} }
@ -354,7 +354,7 @@ namespace YooAsset.Editor
} }
} }
HashSet<int> result = new HashSet<int>(); List<int> result = new List<int>();
foreach (var bundleName in referenceList) foreach (var bundleName in referenceList)
{ {
int bundleID = GetCachedBundleID(bundleName); int bundleID = GetCachedBundleID(bundleName);

View File

@ -153,7 +153,7 @@ namespace YooAsset.Editor
guids = AssetDatabase.FindAssets($"t:{searchType}", searchInFolders); guids = AssetDatabase.FindAssets($"t:{searchType}", searchInFolders);
// 注意AssetDatabase.FindAssets()可能会获取到重复的资源 // 注意AssetDatabase.FindAssets()可能会获取到重复的资源
HashSet<string> result = new HashSet<string>(); List<string> result = new List<string>();
for (int i = 0; i < guids.Length; i++) for (int i = 0; i < guids.Length; i++)
{ {
string guid = guids[i]; string guid = guids[i];

View File

@ -51,9 +51,6 @@ namespace YooAsset
// 准备下载 // 准备下载
if (_steps == ESteps.PrepareDownload) if (_steps == ESteps.PrepareDownload)
{ {
// 获取请求地址
_requestURL = GetRequestURL();
// 重置变量 // 重置变量
_downloadProgress = 0f; _downloadProgress = 0f;
_downloadedBytes = 0; _downloadedBytes = 0;
@ -62,16 +59,14 @@ namespace YooAsset
_isAbort = false; _isAbort = false;
_latestDownloadBytes = 0; _latestDownloadBytes = 0;
_latestDownloadRealtime = Time.realtimeSinceStartup; _latestDownloadRealtime = Time.realtimeSinceStartup;
// 重置计时器
if(_tryAgainTimer > 0f)
YooLogger.Warning($"Try again download : {_requestURL}");
_tryAgainTimer = 0f; _tryAgainTimer = 0f;
// 删除临时文件 // 删除临时文件
if (File.Exists(_tempFilePath)) if (File.Exists(_tempFilePath))
File.Delete(_tempFilePath); File.Delete(_tempFilePath);
// 获取请求地址
_requestURL = GetRequestURL();
_steps = ESteps.CreateDownloader; _steps = ESteps.CreateDownloader;
} }
@ -202,6 +197,7 @@ namespace YooAsset
_failedTryAgain--; _failedTryAgain--;
_steps = ESteps.PrepareDownload; _steps = ESteps.PrepareDownload;
ReportWarning(); ReportWarning();
YooLogger.Warning($"Try again download : {_requestURL}");
} }
} }
} }

View File

@ -91,9 +91,6 @@ namespace YooAsset
// 创建下载器 // 创建下载器
if (_steps == ESteps.PrepareDownload) if (_steps == ESteps.PrepareDownload)
{ {
// 获取请求地址
_requestURL = GetRequestURL();
// 重置变量 // 重置变量
_downloadProgress = 0f; _downloadProgress = 0f;
_downloadedBytes = 0; _downloadedBytes = 0;
@ -102,13 +99,11 @@ namespace YooAsset
_isAbort = false; _isAbort = false;
_latestDownloadBytes = 0; _latestDownloadBytes = 0;
_latestDownloadRealtime = Time.realtimeSinceStartup; _latestDownloadRealtime = Time.realtimeSinceStartup;
_tryAgainTimer = 0f;
_fileOriginLength = 0; _fileOriginLength = 0;
// 重置计时器 // 获取请求地址
if (_tryAgainTimer > 0f) _requestURL = GetRequestURL();
YooLogger.Warning($"Try again download : {_requestURL}");
_tryAgainTimer = 0f;
_steps = ESteps.CreateDownloader; _steps = ESteps.CreateDownloader;
} }
@ -262,6 +257,7 @@ namespace YooAsset
_failedTryAgain--; _failedTryAgain--;
_steps = ESteps.PrepareDownload; _steps = ESteps.PrepareDownload;
ReportWarning(); ReportWarning();
YooLogger.Warning($"Try again download : {_requestURL}");
} }
} }
} }

View File

@ -74,14 +74,14 @@ namespace YooAsset
internal abstract void Start(); internal abstract void Start();
internal abstract void Update(); internal abstract void Update();
internal void SetFinish() internal void OnFinish()
{ {
Progress = 1f; Progress = 1f;
_callback?.Invoke(this); _callback?.Invoke(this);
if (_taskCompletionSource != null) if (_taskCompletionSource != null)
_taskCompletionSource.TrySetResult(null); _taskCompletionSource.TrySetResult(null);
} }
internal void SetStart() internal void OnStart()
{ {
Status = EOperationStatus.Processing; Status = EOperationStatus.Processing;
} }

View File

@ -67,7 +67,7 @@ namespace YooAsset
if (operation.IsDone) if (operation.IsDone)
{ {
_removeList.Add(operation); _removeList.Add(operation);
operation.SetFinish(); operation.OnFinish();
} }
} }
@ -101,7 +101,7 @@ namespace YooAsset
public static void StartOperation(AsyncOperationBase operation) public static void StartOperation(AsyncOperationBase operation)
{ {
_addList.Add(operation); _addList.Add(operation);
operation.SetStart(); operation.OnStart();
operation.Start(); operation.Start();
} }
} }

View File

@ -208,10 +208,6 @@ namespace YooAsset
packageBundle.ParseBundle(Manifest.PackageName, Manifest.OutputNameStyle); packageBundle.ParseBundle(Manifest.PackageName, Manifest.OutputNameStyle);
Manifest.BundleDic.Add(packageBundle.BundleName, packageBundle); Manifest.BundleDic.Add(packageBundle.BundleName, packageBundle);
// 注意原始文件可能存在相同的CacheGUID
if (Manifest.CacheGUIDs.Contains(packageBundle.CacheGUID) == false)
Manifest.CacheGUIDs.Add(packageBundle.CacheGUID);
_packageBundleCount--; _packageBundleCount--;
Progress = 1f - _packageBundleCount / _progressTotalValue; Progress = 1f - _packageBundleCount / _progressTotalValue;
if (OperationSystem.IsBusy) if (OperationSystem.IsBusy)

View File

@ -82,12 +82,6 @@ namespace YooAsset
[NonSerialized] [NonSerialized]
public Dictionary<string, string> AssetPathMapping2; public Dictionary<string, string> AssetPathMapping2;
/// <summary>
/// 该资源清单所有文件的缓存GUID集合
/// </summary>
[NonSerialized]
public HashSet<string> CacheGUIDs = new HashSet<string>();
/// <summary> /// <summary>
/// 尝试映射为资源路径 /// 尝试映射为资源路径
@ -197,7 +191,12 @@ namespace YooAsset
/// </summary> /// </summary>
public bool IsIncludeBundleFile(string cacheGUID) public bool IsIncludeBundleFile(string cacheGUID)
{ {
return CacheGUIDs.Contains(cacheGUID); foreach (var packageBundle in BundleList)
{
if (packageBundle.CacheGUID == cacheGUID)
return true;
}
return false;
} }
/// <summary> /// <summary>

View File

@ -1,6 +1,5 @@
{ {
"name": "YooAsset", "name": "YooAsset",
"rootNamespace": "",
"references": [], "references": [],
"includePlatforms": [], "includePlatforms": [],
"excludePlatforms": [], "excludePlatforms": [],

View File

@ -1,7 +1,7 @@
{ {
"name": "com.tuyoogame.yooasset", "name": "com.tuyoogame.yooasset",
"displayName": "YooAsset", "displayName": "YooAsset",
"version": "1.5.4-preview", "version": "1.5.3-preview",
"unity": "2019.4", "unity": "2019.4",
"description": "unity3d resources management system.", "description": "unity3d resources management system.",
"author": { "author": {