diff --git a/UnityProject/Assets/AssetRaw/Configs/need_cache_list.json b/UnityProject/Assets/AssetRaw/Configs/need_cache_list.json
new file mode 100644
index 00000000..54ea47bc
--- /dev/null
+++ b/UnityProject/Assets/AssetRaw/Configs/need_cache_list.json
@@ -0,0 +1,16 @@
+[
+ {
+ "ResPath": "Assets/AssetRaw/Effects",
+ "CacheTime": 300,
+ "MaxPoolCnt": 30,
+ "PoolGoFreeTime": 300,
+ "MinPoolCnt": 0
+ },
+ {
+ "ResPath": "Assets/AssetRaw/PoolObjects/",
+ "CacheTime": 300,
+ "MaxPoolCnt": 30,
+ "PoolGoFreeTime": 300,
+ "MinPoolCnt": 0
+ }
+]
\ No newline at end of file
diff --git a/UnityProject/Assets/AssetRaw/Configs/need_cache_list.json.meta b/UnityProject/Assets/AssetRaw/Configs/need_cache_list.json.meta
new file mode 100644
index 00000000..4939540e
--- /dev/null
+++ b/UnityProject/Assets/AssetRaw/Configs/need_cache_list.json.meta
@@ -0,0 +1,7 @@
+fileFormatVersion: 2
+guid: c9f7d9280641e9a4b87697ace96a4315
+TextScriptImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/UnityProject/Assets/TEngine/Runtime/Modules/ResourceModule/Pool/ResourceCacheMgr.cs b/UnityProject/Assets/TEngine/Runtime/Modules/ResourceModule/Pool/ResourceCacheMgr.cs
index c1e49f3c..b41e9174 100644
--- a/UnityProject/Assets/TEngine/Runtime/Modules/ResourceModule/Pool/ResourceCacheMgr.cs
+++ b/UnityProject/Assets/TEngine/Runtime/Modules/ResourceModule/Pool/ResourceCacheMgr.cs
@@ -45,6 +45,34 @@ namespace TEngine
/// 持久化的资源起始路径。存在这个路径开始的资源不会释放。
public void RegPersistResPath(List resList) => _needPersistResList.AddRange((IEnumerable)resList);
+ public void InitDefaultCachePool()
+ {
+ if (!ResourceManager.EnableGoPool)
+ {
+ return;
+ }
+
+ string assetLocation = "need_cache_list";
+
+ GameModule.Resource.LoadAssetAsync(assetLocation, handle =>
+ {
+ if (handle.AssetObject == null)
+ {
+ return;
+ }
+ TextAsset textAsset = handle.AssetObject as TextAsset;
+ if (textAsset == null)
+ {
+ return;
+ }
+ List list = Utility.Json.ToObject>(textAsset.text);
+ foreach (var config in list)
+ {
+ Instance.RegCacheResPath(config.ResPath, config.CacheTime, config.MaxPoolCnt, config.PoolGoFreeTime, config.MinPoolCnt);
+ }
+ });
+ }
+
///
/// 注册缓存池的资源。
///
@@ -61,6 +89,10 @@ namespace TEngine
int poolGoFreeTime = 120,
int minPoolCnt = 0)
{
+ if (_enableLog)
+ {
+ Log.Warning($"RegCacheResPath: {resPath} cacheTime: {cacheTime} maxPoolCnt: {maxPoolCnt} poolGoFreeTime: {poolGoFreeTime} minPoolCnt: {minPoolCnt}");
+ }
_needCacheResList.Add(new ResourceCacheConfig(resPath, cacheTime, maxPoolCnt, poolGoFreeTime, minPoolCnt));
}
diff --git a/UnityProject/Assets/TEngine/Runtime/Modules/ResourceModule/ResourceModule.cs b/UnityProject/Assets/TEngine/Runtime/Modules/ResourceModule/ResourceModule.cs
index df6f0d21..e29bf8f7 100644
--- a/UnityProject/Assets/TEngine/Runtime/Modules/ResourceModule/ResourceModule.cs
+++ b/UnityProject/Assets/TEngine/Runtime/Modules/ResourceModule/ResourceModule.cs
@@ -234,7 +234,14 @@ namespace TEngine
///
public InitializationOperation InitPackage(string customPackageName = "")
{
- return m_ResourceManager.InitPackage(customPackageName);
+ InitializationOperation operation = m_ResourceManager.InitPackage(customPackageName);
+
+ operation.Completed += _ =>
+ {
+ ResourceCacheMgr.Instance.InitDefaultCachePool();
+ };
+
+ return operation;
}
///