Skip to content

Commit

Permalink
1.0.56 1.优化资产模块,编辑器模式下增加缓存,加快搜索速度
Browse files Browse the repository at this point in the history
  • Loading branch information
TippingGame committed Nov 4, 2024
1 parent ff99273 commit 8138139
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 26 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## [1.0.56] - 2024-11-04
1.优化资产模块,编辑器模式下增加缓存,加快搜索速度

## [1.0.55] - 2024-11-04
1.修复资产模块协程同时加载报错的问题

Expand Down
42 changes: 17 additions & 25 deletions Runtime/AssetManager/AssetManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1244,37 +1244,28 @@ public float GetLoadProgress()
}

#if UNITY_EDITOR
private List<string> searchDirs = new List<string>();
private Dictionary<string, string> findAssetPaths = new Dictionary<string, string>();
private string SearchAsset(string assetName, System.Object type = default, AssetAccessMode mode = AssetAccessMode.UNKNOWN)
{
// 获取项目中的所有文件夹路径
string[] allFolders = UnityEditor.AssetDatabase.GetAllAssetPaths();
List<string> searchDirs = new List<string>();
// 缓存路径
if (findAssetPaths.TryGetValue(assetName, out string value))
{
return value;
}

// 根据 searchOption 参数决定要搜索的文件夹路径
switch (mode)
if (searchDirs.Count <= 0)
{
case AssetAccessMode.RESOURCE:
foreach (string folderPath in allFolders)
{
if (System.IO.Directory.Exists(folderPath) && folderPath.Contains("/Resources"))
{
searchDirs.Add(folderPath);
}
}
break;
case AssetAccessMode.ASSET_BUNDLE:
searchDirs.Add(System.IO.Path.Combine(URLSetting.AssetBundlesPath));
break;
case AssetAccessMode.UNKNOWN:
foreach (string folderPath in allFolders)
// 获取项目中的所有文件夹路径
string[] allFolders = UnityEditor.AssetDatabase.GetAllAssetPaths();
foreach (string folderPath in allFolders)
{
if (System.IO.Directory.Exists(folderPath) && folderPath.Contains("/Resources"))
{
if (System.IO.Directory.Exists(folderPath) && folderPath.Contains("/Resources"))
{
searchDirs.Add(folderPath);
}
searchDirs.Add(folderPath);
}
searchDirs.Add(System.IO.Path.Combine(URLSetting.AssetBundlesPath));
break;
}
searchDirs.Add(System.IO.Path.Combine(URLSetting.AssetBundlesPath));
}

// 查找指定资源
Expand All @@ -1288,6 +1279,7 @@ private string SearchAsset(string assetName, System.Object type = default, Asset
{
if (Path.GetFileNameWithoutExtension(assetPath) == assetName)
{
findAssetPaths[assetName] = assetPath;
return assetPath;
}
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "com.tippinggame.f8framework",
"displayName": "F8Framework",
"description": "Unity F8Framework Core",
"version": "1.0.55",
"version": "1.0.56",
"unity": "2021.3",
"license": "MIT",
"keywords": ["Unity", "Framework", "Core"],
Expand Down

0 comments on commit 8138139

Please sign in to comment.