Update GameObjectPool.cs

This commit is contained in:
陈思海 2026-03-25 18:41:17 +08:00
parent 4a0465450a
commit c6fe229b4d

View File

@ -9,7 +9,6 @@ using UnityEngine;
namespace AlicizaX
{
/// <summary>
/// 对象池配置项。
/// </summary>
@ -80,6 +79,10 @@ namespace AlicizaX
public bool isRefCountReduced;
[NonSerialized] public PoolObjectMonitor monitor;
public PooledObject()
{
}
public PooledObject(GameObject go, string path)
{
gameObject = go;
@ -223,6 +226,7 @@ namespace AlicizaX
{
availableObjects += queue.Count;
}
loadedPrefabs = pool.LoadedPrefabs.Count;
assetPaths.Clear();
@ -248,6 +252,7 @@ namespace AlicizaX
objectIndex++;
}
}
ReleasePoolObjectInfos(objectIndex);
int prefabIndex = 0;
@ -267,6 +272,7 @@ namespace AlicizaX
info.UpdateFromPrefabRefInfo(kvp.Value);
prefabIndex++;
}
ReleasePrefabRefInfos(prefabIndex);
}
@ -311,6 +317,7 @@ namespace AlicizaX
public class ConfigPool
{
public readonly PoolConfig Config;
// 按资源路径分组的可用对象队列
public readonly Dictionary<string, Queue<PooledObject>> AvailableObjectsByPath;
public readonly HashSet<PooledObject> AllObjects;
@ -536,6 +543,7 @@ namespace AlicizaX
// 只需要从集合中移除,不需要减少引用计数
AllObjects.Remove(obj);
}
continue;
}
@ -611,6 +619,7 @@ namespace AlicizaX
queue = new Queue<PooledObject>();
AvailableObjectsByPath[pooledObj.assetPath] = queue;
}
queue.Enqueue(pooledObj);
}
}
@ -1358,5 +1367,3 @@ namespace AlicizaX
}
}
}