154 changed files with 1231 additions and 2 deletions
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 56a3c8fd9caf0c546b1bfb8443e15ff5 |
||||
folderAsset: yes |
||||
DefaultImporter: |
||||
externalObjects: {} |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2 |
||||
guid: b13727d858ad440da9f62b35a9db05b6 |
||||
timeCreated: 1735826401 |
@ -0,0 +1,56 @@
|
||||
using System; |
||||
using UnityEngine; |
||||
|
||||
namespace Tools.EasyPoolKit |
||||
{ |
||||
public interface ISimpleGameObjectPool : IAbstractPool<GameObject> { } |
||||
|
||||
public interface IRecyclablePool<T> : IAbstractPool<T> where T : class, IRecyclable { } |
||||
|
||||
public interface IAbstractPool<T> where T : class
|
||||
{ |
||||
RecycleObjectType ObjectType { get; } |
||||
|
||||
Type ReferenceType { get; } |
||||
|
||||
string PoolId { get; } |
||||
|
||||
int? InitCreateCount { get; } |
||||
|
||||
int? MaxSpawnCount { get; } |
||||
|
||||
int? MaxDespawnCount { get; } |
||||
|
||||
float? AutoClearTime { get; } |
||||
|
||||
Func<object> SpawnFunc { get; set; } |
||||
|
||||
PoolReachMaxLimitType ReachMaxLimitType { get; } |
||||
|
||||
PoolDespawnDestroyType DespawnDestroyType { get; } |
||||
|
||||
PoolClearType ClearType { get; } |
||||
|
||||
bool IfIgnoreTimeScale { get; } |
||||
|
||||
int GetCachedObjectCount(); |
||||
|
||||
int GetUsedObjectCount(); |
||||
|
||||
int GetTotalObjectCount(); |
||||
|
||||
T SpawnObject(); |
||||
|
||||
bool TrySpawnObject(out T newObj); |
||||
|
||||
bool DespawnObject(T usedObj); |
||||
|
||||
void ClearUnusedObjects(); |
||||
|
||||
void ClearAll(); |
||||
|
||||
void OnPoolUpdate(float deltaTime); |
||||
|
||||
RecyclablePoolInfo GetPoolInfoReadOnly(); |
||||
} |
||||
} |
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 572ab46ede5648ed9221a8d0a59980da |
||||
timeCreated: 1735826434 |
@ -0,0 +1,25 @@
|
||||
namespace Tools.EasyPoolKit |
||||
{ |
||||
public interface IRecyclable |
||||
{ |
||||
RecycleObjectType ObjectType { get; } |
||||
|
||||
string PoolId { get; set; } |
||||
|
||||
int ObjectId { get; set; } |
||||
|
||||
string Name { get; set; } |
||||
|
||||
float UsedTime { get; set; } |
||||
|
||||
void OnObjectInit(); |
||||
|
||||
void OnObjectDeInit(); |
||||
|
||||
void OnObjectSpawn(); |
||||
|
||||
void OnObjectDespawn(); |
||||
|
||||
void OnObjectUpdate(float deltaTime); |
||||
} |
||||
} |
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 0162baae017243bd903260d3037933c3 |
||||
timeCreated: 1735828321 |
@ -0,0 +1,37 @@
|
||||
namespace Tools.EasyPoolKit |
||||
{ |
||||
/// <summary> |
||||
/// 当用户试图获取一个对象,但池达到最大计数<see cref="IAbstractPool{T}.MaxSpawnCount"/> |
||||
/// Default =>创建新对象并返回 |
||||
/// RejectNull =>不创建新对象并返回null |
||||
/// Recycleold => 强制回收最老的并返回,注意:该物体不会执行回收方法 |
||||
/// </summary> |
||||
public enum PoolReachMaxLimitType |
||||
{ |
||||
Default, //无限制 |
||||
RejectNull, |
||||
RecycleOldest, |
||||
} |
||||
|
||||
/// <summary> |
||||
/// 当对象返回给池时,如果池大小大于最大影藏的最大值<see cref="IAbstractPool{T}.MaxDespawnCount"/> |
||||
/// 默认值 => 什么也不做 |
||||
/// DestroyToLimit => 销毁对象,使池大小等于限制 |
||||
/// </summary> |
||||
public enum PoolDespawnDestroyType |
||||
{ |
||||
Default, //Not destroy |
||||
DestroyToLimit, |
||||
} |
||||
|
||||
/// <summary> |
||||
/// 当清除池时 |
||||
/// Default => 清除所有 |
||||
/// ClearToLimit => 清楚掉多余的对象,使池大小等于初始化大小<see cref="IAbstractPool{T}.InitCreateCount"/> |
||||
/// </summary> |
||||
public enum PoolClearType |
||||
{ |
||||
Default, //Clear all |
||||
ClearToLimit, |
||||
} |
||||
} |
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 5f47fcfc58b34733ab5722f55e4b0365 |
||||
timeCreated: 1735826663 |
@ -0,0 +1,21 @@
|
||||
using System; |
||||
|
||||
namespace Tools.EasyPoolKit |
||||
{ |
||||
public sealed class RecyclablePoolConfig |
||||
{ |
||||
public RecycleObjectType ObjectType = RecycleObjectType.Object; |
||||
public Type ReferenceType; |
||||
public string PoolId = string.Empty; |
||||
public Func<object> SpawnFunc; |
||||
public int? InitCreateCount = null; |
||||
public PoolReachMaxLimitType ReachMaxLimitType = PoolReachMaxLimitType.Default; |
||||
public int? MaxSpawnCount = null; |
||||
public PoolDespawnDestroyType DespawnDestroyType = PoolDespawnDestroyType.Default; |
||||
public int? MaxDespawnCount = null; |
||||
public PoolClearType ClearType = PoolClearType.Default; |
||||
public float? AutoClearTime = null; |
||||
public bool IfIgnoreTimeScale = false; |
||||
public object[] ExtraArgs = Array.Empty<object>(); |
||||
} |
||||
} |
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 7bc83b44cc14470ab86d28ae6357d1cf |
||||
timeCreated: 1735829435 |
@ -0,0 +1,108 @@
|
||||
using System; |
||||
|
||||
namespace Tools.EasyPoolKit |
||||
{ |
||||
public sealed class RecyclablePoolInfo |
||||
{ |
||||
public RecycleObjectType ObjectType { get; private set; } = RecycleObjectType.Object; |
||||
public Type ReferenceType { get; private set; } |
||||
public string PoolId { get; private set; } = string.Empty; |
||||
public int? InitCreateCount { get; private set; } = null; |
||||
public PoolReachMaxLimitType ReachMaxLimitType { get; private set; } = PoolReachMaxLimitType.Default; |
||||
public int? MaxSpawnCount { get; private set; } = null; |
||||
public PoolDespawnDestroyType DespawnDestroyType { get; private set; } = PoolDespawnDestroyType.Default; |
||||
public int? MaxDespawnCount { get; private set; } = null; |
||||
public PoolClearType ClearType { get; private set; } = PoolClearType.Default; |
||||
public float? AutoClearTime { get; private set; } = null; |
||||
public bool IfIgnoreTimeScale { get; private set; } = false; |
||||
|
||||
public int CachedObjectCount => _getCachedCount?.Invoke() ?? 0; |
||||
|
||||
public int UsedObjectCount => _getUsedCount?.Invoke() ?? 0; |
||||
|
||||
public int TotalObjectCount => _getTotalCount?.Invoke() ?? 0; |
||||
|
||||
public object ExtraInfo { get; private set; } = null; |
||||
|
||||
private Func<int> _getCachedCount; |
||||
|
||||
private Func<int> _getUsedCount; |
||||
|
||||
private Func<int> _getTotalCount; |
||||
|
||||
public RecyclablePoolInfo(RecyclablePoolConfig config, |
||||
Func<int> getCachedCount, |
||||
Func<int> getUsedCount, |
||||
Func<int> getTotalCount, |
||||
object extraInfo) |
||||
{ |
||||
_getCachedCount = getCachedCount; |
||||
_getUsedCount = getUsedCount; |
||||
_getTotalCount = getTotalCount; |
||||
ObjectType = config.ObjectType; |
||||
ReferenceType = config.ReferenceType; |
||||
PoolId = config.PoolId; |
||||
InitCreateCount = config.InitCreateCount; |
||||
ReachMaxLimitType = config.ReachMaxLimitType; |
||||
MaxSpawnCount = config.MaxSpawnCount; |
||||
DespawnDestroyType = config.DespawnDestroyType; |
||||
MaxDespawnCount = config.MaxDespawnCount; |
||||
ClearType = config.ClearType; |
||||
AutoClearTime = config.AutoClearTime; |
||||
IfIgnoreTimeScale = config.IfIgnoreTimeScale; |
||||
|
||||
_getCachedCount = getCachedCount; |
||||
_getUsedCount = getUsedCount; |
||||
_getTotalCount = getTotalCount; |
||||
ExtraInfo = extraInfo; |
||||
} |
||||
|
||||
public string GetDebugConfigInfo() |
||||
{ |
||||
#if EASY_POOL_DEBUG |
||||
var stringBuilder = new System.Text.StringBuilder(); |
||||
stringBuilder.Append("RecyclablePoolInfo == ConfigInfo\n") |
||||
.Append("PoolID:").Append(PoolId).Append('\n') |
||||
.Append("ObjectType:").Append(ObjectType.ToString()).Append('\n') |
||||
.Append("ReferenceType:").Append(ReferenceType.ToString()).Append('\n') |
||||
.Append("==========").Append(ReferenceType.ToString()).Append('\n') |
||||
.Append("InitCreateCount:").Append(InitCreateCount.HasValue ? InitCreateCount.Value.ToString() : "-").Append('\n') |
||||
.Append("==========").Append(ReferenceType.ToString()).Append('\n') |
||||
.Append("ReachMaxLimitType:").Append(ReachMaxLimitType.ToString()).Append('\n') |
||||
.Append("MaxSpawnCount:").Append(MaxSpawnCount.HasValue ? MaxSpawnCount.Value.ToString() : "-").Append('\n') |
||||
.Append("==========").Append(ReferenceType.ToString()).Append('\n') |
||||
.Append("DespawnDestroyType:").Append(DespawnDestroyType.ToString()).Append('\n') |
||||
.Append("MaxDespawnCount:").Append(MaxDespawnCount.HasValue ? MaxDespawnCount.Value.ToString() : "-").Append('\n') |
||||
.Append("==========").Append(ReferenceType.ToString()).Append('\n') |
||||
.Append("ClearType:").Append(ClearType.ToString()).Append('\n') |
||||
.Append("==========").Append(ReferenceType.ToString()).Append('\n') |
||||
.Append("AutoClearTime:").Append((AutoClearTime.HasValue ? AutoClearTime.Value.ToString() : "-")).Append('\n') |
||||
.Append("==========").Append(ReferenceType.ToString()).Append('\n') |
||||
.Append("IfIgnoreTimeScale:").Append(IfIgnoreTimeScale.ToString()).Append('\n'); |
||||
|
||||
return stringBuilder.ToString(); |
||||
#else |
||||
return string.Empty; |
||||
#endif |
||||
} |
||||
|
||||
public string GetDebugRunningInfo() |
||||
{ |
||||
#if EASY_POOL_DEBUG |
||||
var stringBuilder = new System.Text.StringBuilder(); |
||||
stringBuilder.Append("RecyclablePoolInfo == RunningInfo\n") |
||||
.Append("PoolID:").Append(PoolId).Append('\n') |
||||
.Append("ObjectType:").Append(ObjectType.ToString()).Append('\n') |
||||
.Append("ReferenceType:").Append(ReferenceType.ToString()).Append('\n') |
||||
.Append("==========").Append(ReferenceType.ToString()).Append('\n') |
||||
.Append("CachedObjectCount:").Append(CachedObjectCount).Append('/').Append(TotalObjectCount).Append('\n') |
||||
.Append("UsedObjectCount:").Append(UsedObjectCount).Append('/').Append(TotalObjectCount).Append('\n') |
||||
.Append("TotalObjectCount").Append('/').Append("MaxSpawnCount:").Append(MaxSpawnCount.HasValue ? MaxSpawnCount.Value.ToString() : "-").Append('\n'); |
||||
|
||||
return stringBuilder.ToString(); |
||||
#else |
||||
return string.Empty; |
||||
#endif |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 3de3c660f50a47e8bc523edfadb526c3 |
||||
timeCreated: 1735829404 |
@ -0,0 +1,9 @@
|
||||
namespace Tools.EasyPoolKit |
||||
{ |
||||
public enum RecycleObjectType |
||||
{ |
||||
Object, |
||||
RecyclableGameObject, |
||||
GameObject, |
||||
} |
||||
} |
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 2a088bae858a4f58a733fc0ac9ef0594 |
||||
timeCreated: 1735826482 |
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 84918e1e29eb44b08f12e0c4860711d6 |
||||
timeCreated: 1735828525 |
@ -0,0 +1,400 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using UnityEngine; |
||||
using UnityEngine.Assertions; |
||||
|
||||
namespace Tools.EasyPoolKit |
||||
{ |
||||
public class SimpleGameObjectPool : ISimpleGameObjectPool |
||||
{ |
||||
private Transform _cachedRoot; // 影藏位置 |
||||
protected Queue<GameObject> CachedQueue { get; private set; } // 影藏队列 |
||||
protected LinkedList<GameObject> UsedList { get; private set; } |
||||
protected Dictionary<int, float> UsedTimeDic { get; private set; } |
||||
private int _objectCounter = 0; |
||||
private bool _ifInit = false; |
||||
|
||||
public RecycleObjectType ObjectType => RecycleObjectType.GameObject; |
||||
public Type ReferenceType { get; private set; } |
||||
public string PoolId { get; private set; } |
||||
public int? InitCreateCount { get; private set; } |
||||
public int? MaxSpawnCount { get; private set; } |
||||
public int? MaxDespawnCount { get; private set; } |
||||
public float? AutoClearTime { get; private set; } |
||||
public Func<object> SpawnFunc { get; set; } |
||||
public PoolReachMaxLimitType ReachMaxLimitType { get; private set; } |
||||
public PoolDespawnDestroyType DespawnDestroyType { get; private set; } |
||||
public PoolClearType ClearType { get; private set; } |
||||
public bool IfIgnoreTimeScale { get; private set; } |
||||
|
||||
public int GetCachedObjectCount() => CachedQueue.Count; |
||||
public int GetUsedObjectCount() => UsedList.Count; |
||||
public int GetTotalObjectCount() => CachedQueue.Count + UsedList.Count; |
||||
|
||||
protected RecyclablePoolInfo PoolInfo; |
||||
|
||||
public SimpleGameObjectPool(RecyclablePoolConfig config) |
||||
{ |
||||
InitByConfig(config); |
||||
} |
||||
|
||||
protected RecyclablePoolInfo InitByConfig(RecyclablePoolConfig config) |
||||
{ |
||||
Assert.IsTrue(!_ifInit); |
||||
Assert.IsNotNull(config); |
||||
Assert.IsNotNull(config.SpawnFunc); |
||||
Assert.IsTrue(config.ObjectType == RecycleObjectType.GameObject); |
||||
|
||||
ReferenceType = config.ReferenceType; |
||||
PoolId = config.PoolId; |
||||
SpawnFunc = config.SpawnFunc; |
||||
ReachMaxLimitType = config.ReachMaxLimitType; |
||||
DespawnDestroyType = config.DespawnDestroyType; |
||||
ClearType = config.ClearType; |
||||
InitCreateCount = config.InitCreateCount; |
||||
MaxSpawnCount = config.MaxSpawnCount; |
||||
MaxDespawnCount = config.MaxDespawnCount; |
||||
AutoClearTime = config.AutoClearTime; |
||||
IfIgnoreTimeScale = config.IfIgnoreTimeScale; |
||||
|
||||
PoolInfo = new RecyclablePoolInfo(config, GetCachedObjectCount, GetUsedObjectCount, GetTotalObjectCount, this); |
||||
|
||||
CachedQueue = MaxSpawnCount.HasValue |
||||
? new Queue<GameObject>(MaxSpawnCount.Value + 1) |
||||
: new Queue<GameObject>(); |
||||
UsedList = new LinkedList<GameObject>(); |
||||
UsedTimeDic = new Dictionary<int, float>(); |
||||
|
||||
OnInitByParams(config.ExtraArgs); |
||||
InitCachedPool(); |
||||
_ifInit = true; |
||||
|
||||
#if EASY_POOL_DEBUG |
||||
Debug.Log($"EasyPoolKit == Create:Root:\n{GetDebugConfigInfo()}"); |
||||
|
||||
// 检测配置是否合法 |
||||
if (ReachMaxLimitType is PoolReachMaxLimitType.RecycleOldest or PoolReachMaxLimitType.RecycleOldest) |
||||
{ |
||||
Assert.IsTrue(MaxSpawnCount is > 0); |
||||
} |
||||
|
||||
if (DespawnDestroyType is PoolDespawnDestroyType.DestroyToLimit) |
||||
{ |
||||
Assert.IsTrue(MaxDespawnCount is > 0); |
||||
} |
||||
|
||||
if (MaxDespawnCount.HasValue && MaxSpawnCount.HasValue) |
||||
{ |
||||
Assert.IsTrue(MaxDespawnCount.Value <= MaxSpawnCount.Value); |
||||
} |
||||
|
||||
if (InitCreateCount.HasValue && MaxSpawnCount.HasValue) |
||||
{ |
||||
Assert.IsTrue(InitCreateCount.Value <= MaxSpawnCount.Value); |
||||
} |
||||
#endif |
||||
return PoolInfo; |
||||
} |
||||
|
||||
protected virtual void OnInitByParams(object[] args) |
||||
{ |
||||
var extraArgs = args; |
||||
|
||||
if (extraArgs != null && extraArgs.Length > 0 && extraArgs[0] is Transform root) |
||||
{ |
||||
_cachedRoot = root; |
||||
} |
||||
else |
||||
{ |
||||
Debug.LogError("EasyPoolKit == 创建Mono物体时,extraArgs[0]应该输入Transform当做父节点"); |
||||
} |
||||
} |
||||
|
||||
private void InitCachedPool() |
||||
{ |
||||
if (!InitCreateCount.HasValue) |
||||
{ |
||||
return; |
||||
} |
||||
|
||||
var initCount = InitCreateCount.Value; |
||||
|
||||
for (int i = 0; i < initCount; i++) |
||||
{ |
||||
var cachedObj = CreateObject(); |
||||
CachedQueue.Enqueue(cachedObj); |
||||
OnObjectEnqueue(cachedObj); |
||||
} |
||||
} |
||||
|
||||
protected virtual void OnObjectInit(GameObject usedObj){ } |
||||
protected virtual void OnObjectEnqueue(GameObject usedObj) => usedObj.transform.SetParent(_cachedRoot, true); |
||||
protected virtual void OnObjectDequeue(GameObject usedObj) => usedObj.transform.SetParent(null, true); |
||||
protected virtual void OnObjectDeInit(GameObject usedObj) |
||||
{ |
||||
if (usedObj) |
||||
{ |
||||
UnityEngine.Object.Destroy(usedObj); |
||||
} |
||||
} |
||||
|
||||
|
||||
// 内部方法,快速创建对象,不做繁琐的检查 |
||||
private GameObject CreateObject() |
||||
{ |
||||
_objectCounter++; |
||||
var cachedObj = SpawnFunc?.Invoke() as GameObject; |
||||
|
||||
if (cachedObj) |
||||
{ |
||||
#if EASY_POOL_DEBUG |
||||
cachedObj.name = $"{PoolId}_{_objectCounter}"; |
||||
#endif |
||||
OnObjectInit(cachedObj); |
||||
} |
||||
#if EASY_POOL_DEBUG |
||||
else |
||||
{ |
||||
Debug.LogError($"EasyPoolKit == GenerateObject {PoolId} 创建的物体不该为空!"); |
||||
} |
||||
#endif |
||||
|
||||
return cachedObj; |
||||
} |
||||
|
||||
|
||||
public GameObject SpawnObject() |
||||
{ |
||||
GameObject cachedObj = null; |
||||
|
||||
if (GetCachedObjectCount() > 0) |
||||
{ |
||||
cachedObj = CachedQueue.Dequeue(); |
||||
} |
||||
else |
||||
{ |
||||
bool ifReachLimit = false; |
||||
|
||||
if (ReachMaxLimitType != PoolReachMaxLimitType.Default && MaxSpawnCount.HasValue) |
||||
{ |
||||
ifReachLimit = GetTotalObjectCount() >= MaxSpawnCount.Value; |
||||
} |
||||
|
||||
if (!ifReachLimit) |
||||
{ |
||||
cachedObj = CreateObject(); |
||||
} |
||||
else |
||||
{ |
||||
switch (ReachMaxLimitType) |
||||
{ |
||||
case PoolReachMaxLimitType.RecycleOldest: |
||||
cachedObj = RecycleOldestObject(); |
||||
break; |
||||
case PoolReachMaxLimitType.Default: |
||||
// 不可达到 |
||||
case PoolReachMaxLimitType.RejectNull: |
||||
default: |
||||
// 什么都不做 |
||||
break; |
||||
} |
||||
} |
||||
} |
||||
|
||||
if (cachedObj != null) |
||||
{ |
||||
OnObjectEnqueue(cachedObj); |
||||
UsedList.AddLast(cachedObj); |
||||
UsedTimeDic[cachedObj.GetInstanceID()] = 0; |
||||
} |
||||
|
||||
return cachedObj; |
||||
|
||||
GameObject RecycleOldestObject() |
||||
{ |
||||
#if EASY_POOL_DEBUG |
||||
Assert.IsTrue(GetUsedObjectCount() > 0, $"EasyPoolKit == RecycleOldestObject {PoolId} 回收最老的物体时 UsedCount should > 0"); |
||||
#endif |
||||
var firstNode = UsedList.First; |
||||
UsedList.Remove(firstNode); |
||||
var oldestObj = firstNode.Value; |
||||
|
||||
#if EASY_POOL_DEBUG |
||||
if (!oldestObj) |
||||
{ |
||||
Debug.LogError($"EasyPoolKit == RecycleOldestObject {PoolId} 回收最老的物体时 OldestObj should not be null"); |
||||
} |
||||
#endif |
||||
|
||||
// 直接将该物体作为新物体使用,不添加到CachedQueue,也不执行OnObjectEnqueue |
||||
return oldestObj; |
||||
} |
||||
} |
||||
|
||||
public bool TrySpawnObject(out GameObject newObj) |
||||
{ |
||||
newObj = SpawnObject(); |
||||
return newObj != null; |
||||
} |
||||
|
||||
public bool DespawnObject(GameObject usedObj) |
||||
{ |
||||
#if EASY_POOL_DEBUG |
||||
if (usedObj == null) |
||||
{ |
||||
Debug.LogError("EasyPoolKit == 回收的物体不能为空"); |
||||
return false; |
||||
} |
||||
#endif |
||||
var usedNode = UsedList.Find(usedObj); |
||||
if (usedNode == null) |
||||
{ |
||||
Debug.LogError($"EasyPoolKit == 无法回收该物体,该物体并不在使用物体队列中:{usedObj.name}"); |
||||
} |
||||
|
||||
bool ifReachLimit = false; |
||||
|
||||
if (DespawnDestroyType == PoolDespawnDestroyType.DestroyToLimit) |
||||
{ |
||||
// if (MaxDespawnCount.HasValue && GetCachedObjectCount() > MaxDespawnCount.Value) |
||||
if (MaxDespawnCount.HasValue && GetCachedObjectCount() > MaxDespawnCount.Value) |
||||
{ |
||||
ifReachLimit = true; |
||||
} |
||||
} |
||||
|
||||
UsedList.Remove(usedNode); |
||||
UsedTimeDic.Remove(usedObj.GetInstanceID()); |
||||
|
||||
if (ifReachLimit) |
||||
{ |
||||
DestroyPoolObject(usedObj); |
||||
} |
||||
else |
||||
{ |
||||
CachedQueue.Enqueue(usedObj); |
||||
OnObjectEnqueue(usedObj); |
||||
} |
||||
|
||||
return true; |
||||
} |
||||
|
||||
public void ClearUnusedObjects() |
||||
{ |
||||
foreach (var cachedItem in CachedQueue) |
||||
{ |
||||
DestroyPoolObject(cachedItem); |
||||
} |
||||
CachedQueue.Clear(); |
||||
} |
||||
|
||||
public void ClearAll() |
||||
{ |
||||
switch (ClearType) |
||||
{ |
||||
case PoolClearType.Default: |
||||
PoolClearAll(); |
||||
break; |
||||
case PoolClearType.ClearToLimit: |
||||
PoolClearToLimit(); |
||||
break; |
||||
} |
||||
} |
||||
|
||||
public void OnPoolUpdate(float deltaTime) |
||||
{ |
||||
if (UsedList.Count > 0) |
||||
{ |
||||
var node = UsedList.First; |
||||
float collectTime = AutoClearTime ?? -1f; |
||||
while (node != null) |
||||
{ |
||||
var currentNode = node; |
||||
node = node.Next; |
||||
var usedObj = currentNode.Value; |
||||
|
||||
var objId = usedObj.GetInstanceID(); |
||||
|
||||
var usedTime = UsedTimeDic[objId]; |
||||
UsedTimeDic[objId] = usedTime + deltaTime; |
||||
|
||||
if (collectTime > 0 && usedTime >= collectTime) |
||||
{ |
||||
DespawnObject(usedObj); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
public RecyclablePoolInfo GetPoolInfoReadOnly() => PoolInfo; |
||||
|
||||
private void DestroyPoolObject(GameObject poolObj) |
||||
{ |
||||
if (poolObj) |
||||
{ |
||||
OnObjectDeInit(poolObj); |
||||
} |
||||
} |
||||
|
||||
private void PoolClearAll() |
||||
{ |
||||
ClearUnusedObjects(); |
||||
|
||||
while (UsedList.Count > 0) |
||||
{ |
||||
var firstNode = UsedList.First; |
||||
var firstObj = firstNode.Value; |
||||
UsedList.Remove(firstNode); |
||||
DestroyPoolObject(firstObj); |
||||
} |
||||
|
||||
UsedList.Clear(); |
||||
} |
||||
|
||||
private void PoolClearToLimit() |
||||
{ |
||||
if (!InitCreateCount.HasValue) |
||||
{ |
||||
PoolClearAll(); |
||||
return; |
||||
} |
||||
|
||||
PoolClearRetain(); |
||||
|
||||
int removeCount = GetCachedObjectCount() - InitCreateCount.Value; |
||||
|
||||
while (removeCount > 0) |
||||
{ |
||||
removeCount--; |
||||
var cachedObj = CachedQueue.Dequeue(); |
||||
DestroyPoolObject(cachedObj); |
||||
} |
||||
} |
||||
|
||||
/// 回收正在使用的物体 |
||||
private void PoolClearRetain() |
||||
{ |
||||
while (UsedList.Count > 0) |
||||
{ |
||||
var firstNode = UsedList.First; |
||||
var firstObj = firstNode.Value; |
||||
DespawnObject(firstObj); |
||||
} |
||||
} |
||||
|
||||
|
||||
#region Debug |
||||
|
||||
public string GetDebugConfigInfo() |
||||
{ |
||||
return PoolInfo?.GetDebugConfigInfo() ?? string.Empty; |
||||
} |
||||
|
||||
public string GetDebugRunningInfo() |
||||
{ |
||||
return PoolInfo?.GetDebugRunningInfo() ?? string.Empty; |
||||
} |
||||
|
||||
#endregion |
||||
} |
||||
} |
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 4157f7b19be94bedaf91bfe7ee06a69e |
||||
timeCreated: 1735828587 |
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 42040b2b14ed8dd408545a2e51c478f8 |
||||
folderAsset: yes |
||||
DefaultImporter: |
||||
externalObjects: {} |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2 |
||||
guid: d5b1a5bf68769254180b013c85e55147 |
||||
folderAsset: yes |
||||
DefaultImporter: |
||||
externalObjects: {} |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -0,0 +1,495 @@
|
||||
%YAML 1.1 |
||||
%TAG !u! tag:unity3d.com,2011: |
||||
--- !u!29 &1 |
||||
OcclusionCullingSettings: |
||||
m_ObjectHideFlags: 0 |
||||
serializedVersion: 2 |
||||
m_OcclusionBakeSettings: |
||||
smallestOccluder: 5 |
||||
smallestHole: 0.25 |
||||
backfaceThreshold: 100 |
||||
m_SceneGUID: 00000000000000000000000000000000 |
||||
m_OcclusionCullingData: {fileID: 0} |
||||
--- !u!104 &2 |
||||
RenderSettings: |
||||
m_ObjectHideFlags: 0 |
||||
serializedVersion: 10 |
||||
m_Fog: 0 |
||||
m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} |
||||
m_FogMode: 3 |
||||
m_FogDensity: 0.01 |
||||
m_LinearFogStart: 0 |
||||
m_LinearFogEnd: 300 |
||||
m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} |
||||
m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} |
||||
m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} |
||||
m_AmbientIntensity: 1 |
||||
m_AmbientMode: 0 |
||||
m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1} |
||||
m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0} |
||||
m_HaloStrength: 0.5 |
||||
m_FlareStrength: 1 |
||||
m_FlareFadeSpeed: 3 |
||||
m_HaloTexture: {fileID: 0} |
||||
m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} |
||||
m_DefaultReflectionMode: 0 |
||||
m_DefaultReflectionResolution: 128 |
||||
m_ReflectionBounces: 1 |
||||
m_ReflectionIntensity: 1 |
||||
m_CustomReflection: {fileID: 0} |
||||
m_Sun: {fileID: 0} |
||||
m_UseRadianceAmbientProbe: 0 |
||||
--- !u!157 &3 |
||||
LightmapSettings: |
||||
m_ObjectHideFlags: 0 |
||||
serializedVersion: 13 |
||||
m_BakeOnSceneLoad: 0 |
||||
m_GISettings: |
||||
serializedVersion: 2 |
||||
m_BounceScale: 1 |
||||
m_IndirectOutputScale: 1 |
||||
m_AlbedoBoost: 1 |
||||
m_EnvironmentLightingMode: 0 |
||||
m_EnableBakedLightmaps: 1 |
||||
m_EnableRealtimeLightmaps: 0 |
||||
m_LightmapEditorSettings: |
||||
serializedVersion: 12 |
||||
m_Resolution: 2 |
||||
m_BakeResolution: 40 |
||||
m_AtlasSize: 1024 |
||||
m_AO: 0 |
||||
m_AOMaxDistance: 1 |
||||
m_CompAOExponent: 1 |
||||
m_CompAOExponentDirect: 0 |
||||
m_ExtractAmbientOcclusion: 0 |
||||
m_Padding: 2 |
||||
m_LightmapParameters: {fileID: 0} |
||||
m_LightmapsBakeMode: 1 |
||||
m_TextureCompression: 1 |
||||
m_ReflectionCompression: 2 |
||||
m_MixedBakeMode: 2 |
||||
m_BakeBackend: 1 |
||||
m_PVRSampling: 1 |
||||
m_PVRDirectSampleCount: 32 |
||||
m_PVRSampleCount: 512 |
||||
m_PVRBounces: 2 |
||||
m_PVREnvironmentSampleCount: 256 |
||||
m_PVREnvironmentReferencePointCount: 2048 |
||||
m_PVRFilteringMode: 1 |
||||
m_PVRDenoiserTypeDirect: 1 |
||||
m_PVRDenoiserTypeIndirect: 1 |
||||
m_PVRDenoiserTypeAO: 1 |
||||
m_PVRFilterTypeDirect: 0 |
||||
m_PVRFilterTypeIndirect: 0 |
||||
m_PVRFilterTypeAO: 0 |
||||
m_PVREnvironmentMIS: 1 |
||||
m_PVRCulling: 1 |
||||
m_PVRFilteringGaussRadiusDirect: 1 |
||||
m_PVRFilteringGaussRadiusIndirect: 1 |
||||
m_PVRFilteringGaussRadiusAO: 1 |
||||
m_PVRFilteringAtrousPositionSigmaDirect: 0.5 |
||||
m_PVRFilteringAtrousPositionSigmaIndirect: 2 |
||||
m_PVRFilteringAtrousPositionSigmaAO: 1 |
||||
m_ExportTrainingData: 0 |
||||
m_TrainingDataDestination: TrainingData |
||||
m_LightProbeSampleCountMultiplier: 4 |
||||
m_LightingDataAsset: {fileID: 20201, guid: 0000000000000000f000000000000000, type: 0} |
||||
m_LightingSettings: {fileID: 0} |
||||
--- !u!196 &4 |
||||
NavMeshSettings: |
||||
serializedVersion: 2 |
||||
m_ObjectHideFlags: 0 |
||||
m_BuildSettings: |
||||
serializedVersion: 3 |
||||
agentTypeID: 0 |
||||
agentRadius: 0.5 |
||||
agentHeight: 2 |
||||
agentSlope: 45 |
||||
agentClimb: 0.4 |
||||
ledgeDropHeight: 0 |
||||
maxJumpAcrossDistance: 0 |
||||
minRegionArea: 2 |
||||
manualCellSize: 0 |
||||
cellSize: 0.16666667 |
||||
manualTileSize: 0 |
||||
tileSize: 256 |
||||
buildHeightMesh: 0 |
||||
maxJobWorkers: 0 |
||||
preserveTilesOutsideBounds: 0 |
||||
debug: |
||||
m_Flags: 0 |
||||
m_NavMeshData: {fileID: 0} |
||||
--- !u!1 &65465572 |
||||
GameObject: |
||||
m_ObjectHideFlags: 0 |
||||
m_CorrespondingSourceObject: {fileID: 0} |
||||
m_PrefabInstance: {fileID: 0} |
||||
m_PrefabAsset: {fileID: 0} |
||||
serializedVersion: 6 |
||||
m_Component: |
||||
- component: {fileID: 65465575} |
||||
- component: {fileID: 65465574} |
||||
- component: {fileID: 65465573} |
||||
m_Layer: 0 |
||||
m_Name: Main Camera |
||||
m_TagString: MainCamera |
||||
m_Icon: {fileID: 0} |
||||
m_NavMeshLayer: 0 |
||||
m_StaticEditorFlags: 0 |
||||
m_IsActive: 1 |
||||
--- !u!81 &65465573 |
||||
AudioListener: |
||||
m_ObjectHideFlags: 0 |
||||
m_CorrespondingSourceObject: {fileID: 0} |
||||
m_PrefabInstance: {fileID: 0} |
||||
m_PrefabAsset: {fileID: 0} |
||||
m_GameObject: {fileID: 65465572} |
||||
m_Enabled: 1 |
||||
--- !u!20 &65465574 |
||||
Camera: |
||||
m_ObjectHideFlags: 0 |
||||
m_CorrespondingSourceObject: {fileID: 0} |
||||
m_PrefabInstance: {fileID: 0} |
||||
m_PrefabAsset: {fileID: 0} |
||||
m_GameObject: {fileID: 65465572} |
||||
m_Enabled: 1 |
||||
serializedVersion: 2 |
||||
m_ClearFlags: 1 |
||||
m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0} |
||||
m_projectionMatrixMode: 1 |
||||
m_GateFitMode: 2 |
||||
m_FOVAxisMode: 0 |
||||
m_Iso: 200 |
||||
m_ShutterSpeed: 0.005 |
||||
m_Aperture: 16 |
||||
m_FocusDistance: 10 |
||||
m_FocalLength: 50 |
||||
m_BladeCount: 5 |
||||
m_Curvature: {x: 2, y: 11} |
||||
m_BarrelClipping: 0.25 |
||||
m_Anamorphism: 0 |
||||
m_SensorSize: {x: 36, y: 24} |
||||
m_LensShift: {x: 0, y: 0} |
||||
m_NormalizedViewPortRect: |
||||
serializedVersion: 2 |
||||
x: 0 |
||||
y: 0 |
||||
width: 1 |
||||
height: 1 |
||||
near clip plane: 0.3 |
||||
far clip plane: 1000 |
||||
field of view: 60 |
||||
orthographic: 0 |
||||
orthographic size: 5 |
||||
m_Depth: -1 |
||||
m_CullingMask: |
||||
serializedVersion: 2 |
||||
m_Bits: 4294967295 |
||||
m_RenderingPath: -1 |
||||
m_TargetTexture: {fileID: 0} |
||||
m_TargetDisplay: 0 |
||||
m_TargetEye: 3 |
||||
m_HDR: 1 |
||||
m_AllowMSAA: 1 |
||||
m_AllowDynamicResolution: 0 |
||||
m_ForceIntoRT: 0 |
||||
m_OcclusionCulling: 1 |
||||
m_StereoConvergence: 10 |
||||
m_StereoSeparation: 0.022 |
||||
--- !u!4 &65465575 |
||||
Transform: |
||||
m_ObjectHideFlags: 0 |
||||
m_CorrespondingSourceObject: {fileID: 0} |
||||
m_PrefabInstance: {fileID: 0} |
||||
m_PrefabAsset: {fileID: 0} |
||||
m_GameObject: {fileID: 65465572} |
||||
serializedVersion: 2 |
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} |
||||
m_LocalPosition: {x: 0, y: 1, z: -10} |
||||
m_LocalScale: {x: 1, y: 1, z: 1} |
||||
m_ConstrainProportionsScale: 0 |
||||
m_Children: [] |
||||
m_Father: {fileID: 0} |
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} |
||||
--- !u!1 &79651670 |
||||
GameObject: |
||||
m_ObjectHideFlags: 0 |
||||
m_CorrespondingSourceObject: {fileID: 0} |
||||
m_PrefabInstance: {fileID: 0} |
||||
m_PrefabAsset: {fileID: 0} |
||||
serializedVersion: 6 |
||||
m_Component: |
||||
- component: {fileID: 79651672} |
||||
- component: {fileID: 79651671} |
||||
- component: {fileID: 79651673} |
||||
m_Layer: 0 |
||||
m_Name: Directional Light |
||||
m_TagString: Untagged |
||||
m_Icon: {fileID: 0} |
||||
m_NavMeshLayer: 0 |
||||
m_StaticEditorFlags: 0 |
||||
m_IsActive: 1 |
||||
--- !u!108 &79651671 |
||||
Light: |
||||
m_ObjectHideFlags: 0 |
||||
m_CorrespondingSourceObject: {fileID: 0} |
||||
m_PrefabInstance: {fileID: 0} |
||||
m_PrefabAsset: {fileID: 0} |
||||
m_GameObject: {fileID: 79651670} |
||||
m_Enabled: 1 |
||||
serializedVersion: 11 |
||||
m_Type: 1 |
||||
m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1} |
||||
m_Intensity: 1 |
||||
m_Range: 10 |
||||
m_SpotAngle: 30 |
||||
m_InnerSpotAngle: 21.80208 |
||||
m_CookieSize: 10 |
||||
m_Shadows: |
||||
m_Type: 2 |
||||
m_Resolution: -1 |
||||
m_CustomResolution: -1 |
||||
m_Strength: 1 |
||||
m_Bias: 0.05 |
||||
m_NormalBias: 0.4 |
||||
m_NearPlane: 0.2 |
||||
m_CullingMatrixOverride: |
||||
e00: 1 |
||||
e01: 0 |
||||
e02: 0 |
||||
e03: 0 |
||||
e10: 0 |
||||
e11: 1 |
||||
e12: 0 |
||||
e13: 0 |
||||
e20: 0 |
||||
e21: 0 |
||||
e22: 1 |
||||
e23: 0 |
||||
e30: 0 |
||||
e31: 0 |
||||
e32: 0 |
||||
e33: 1 |
||||
m_UseCullingMatrixOverride: 0 |
||||
m_Cookie: {fileID: 0} |
||||
m_DrawHalo: 0 |
||||
m_Flare: {fileID: 0} |
||||
m_RenderMode: 0 |
||||
m_CullingMask: |
||||
serializedVersion: 2 |
||||
m_Bits: 4294967295 |
||||
m_RenderingLayerMask: 1 |
||||
m_Lightmapping: 4 |
||||
m_LightShadowCasterMode: 0 |
||||
m_AreaSize: {x: 1, y: 1} |
||||
m_BounceIntensity: 1 |
||||
m_ColorTemperature: 6570 |
||||
m_UseColorTemperature: 0 |
||||
m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0} |
||||
m_UseBoundingSphereOverride: 0 |
||||
m_UseViewFrustumForShadowCasterCull: 1 |
||||
m_ForceVisible: 0 |
||||
m_ShadowRadius: 0 |
||||
m_ShadowAngle: 0 |
||||
m_LightUnit: 1 |
||||
m_LuxAtDistance: 1 |
||||
m_EnableSpotReflector: 1 |
||||
--- !u!4 &79651672 |
||||
Transform: |
||||
m_ObjectHideFlags: 0 |
||||
m_CorrespondingSourceObject: {fileID: 0} |
||||
m_PrefabInstance: {fileID: 0} |
||||
m_PrefabAsset: {fileID: 0} |
||||
m_GameObject: {fileID: 79651670} |
||||
serializedVersion: 2 |
||||
m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261} |
||||
m_LocalPosition: {x: 0, y: 3, z: 0} |
||||
m_LocalScale: {x: 1, y: 1, z: 1} |
||||
m_ConstrainProportionsScale: 0 |
||||
m_Children: [] |
||||
m_Father: {fileID: 0} |
||||
m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} |
||||
--- !u!114 &79651673 |
||||
MonoBehaviour: |
||||
m_ObjectHideFlags: 0 |
||||
m_CorrespondingSourceObject: {fileID: 0} |
||||
m_PrefabInstance: {fileID: 0} |
||||
m_PrefabAsset: {fileID: 0} |
||||
m_GameObject: {fileID: 79651670} |
||||
m_Enabled: 1 |
||||
m_EditorHideFlags: 0 |
||||
m_Script: {fileID: 11500000, guid: 474bcb49853aa07438625e644c072ee6, type: 3} |
||||
m_Name: |
||||
m_EditorClassIdentifier: |
||||
m_Version: 3 |
||||
m_UsePipelineSettings: 1 |
||||
m_AdditionalLightsShadowResolutionTier: 2 |
||||
m_LightLayerMask: 1 |
||||
m_RenderingLayers: 1 |
||||
m_CustomShadowLayers: 0 |
||||
m_ShadowLayerMask: 1 |
||||
m_ShadowRenderingLayers: 1 |
||||
m_LightCookieSize: {x: 1, y: 1} |
||||
m_LightCookieOffset: {x: 0, y: 0} |
||||
m_SoftShadowQuality: 0 |
||||
--- !u!1 &1887936863 |
||||
GameObject: |
||||
m_ObjectHideFlags: 0 |
||||
m_CorrespondingSourceObject: {fileID: 0} |
||||
m_PrefabInstance: {fileID: 0} |
||||
m_PrefabAsset: {fileID: 0} |
||||
serializedVersion: 6 |
||||
m_Component: |
||||
- component: {fileID: 1887936864} |
||||
- component: {fileID: 1887936865} |
||||
m_Layer: 0 |
||||
m_Name: Manager |
||||
m_TagString: Untagged |
||||
m_Icon: {fileID: 0} |
||||
m_NavMeshLayer: 0 |
||||
m_StaticEditorFlags: 0 |
||||
m_IsActive: 1 |
||||
--- !u!4 &1887936864 |
||||
Transform: |
||||
m_ObjectHideFlags: 0 |
||||
m_CorrespondingSourceObject: {fileID: 0} |
||||
m_PrefabInstance: {fileID: 0} |
||||
m_PrefabAsset: {fileID: 0} |
||||
m_GameObject: {fileID: 1887936863} |
||||
serializedVersion: 2 |
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} |
||||
m_LocalPosition: {x: 0, y: 0, z: 0} |
||||
m_LocalScale: {x: 1, y: 1, z: 1} |
||||
m_ConstrainProportionsScale: 0 |
||||
m_Children: [] |
||||
m_Father: {fileID: 0} |
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} |
||||
--- !u!114 &1887936865 |
||||
MonoBehaviour: |
||||
m_ObjectHideFlags: 0 |
||||
m_CorrespondingSourceObject: {fileID: 0} |
||||
m_PrefabInstance: {fileID: 0} |
||||
m_PrefabAsset: {fileID: 0} |
||||
m_GameObject: {fileID: 1887936863} |
||||
m_Enabled: 1 |
||||
m_EditorHideFlags: 0 |
||||
m_Script: {fileID: 11500000, guid: c53679ae49565704d8a17892b9bbc378, type: 3} |
||||
m_Name: |
||||
m_EditorClassIdentifier: |
||||
prefab: {fileID: 2037916656} |
||||
--- !u!1 &2037916656 |
||||
GameObject: |
||||
m_ObjectHideFlags: 0 |
||||
m_CorrespondingSourceObject: {fileID: 0} |
||||
m_PrefabInstance: {fileID: 0} |
||||
m_PrefabAsset: {fileID: 0} |
||||
serializedVersion: 6 |
||||
m_Component: |
||||
- component: {fileID: 2037916660} |
||||
- component: {fileID: 2037916659} |
||||
- component: {fileID: 2037916658} |
||||
- component: {fileID: 2037916657} |
||||
m_Layer: 0 |
||||
m_Name: Cube |
||||
m_TagString: Untagged |
||||
m_Icon: {fileID: 0} |
||||
m_NavMeshLayer: 0 |
||||
m_StaticEditorFlags: 0 |
||||
m_IsActive: 1 |
||||
--- !u!65 &2037916657 |
||||
BoxCollider: |
||||
m_ObjectHideFlags: 0 |
||||
m_CorrespondingSourceObject: {fileID: 0} |
||||
m_PrefabInstance: {fileID: 0} |
||||
m_PrefabAsset: {fileID: 0} |
||||
m_GameObject: {fileID: 2037916656} |
||||
m_Material: {fileID: 0} |
||||
m_IncludeLayers: |
||||
serializedVersion: 2 |
||||
m_Bits: 0 |
||||
m_ExcludeLayers: |
||||
serializedVersion: 2 |
||||
m_Bits: 0 |
||||
m_LayerOverridePriority: 0 |
||||
m_IsTrigger: 0 |
||||
m_ProvidesContacts: 0 |
||||
m_Enabled: 1 |
||||
serializedVersion: 3 |
||||
m_Size: {x: 1, y: 1, z: 1} |
||||
m_Center: {x: 0, y: 0, z: 0} |
||||
--- !u!23 &2037916658 |
||||
MeshRenderer: |
||||
m_ObjectHideFlags: 0 |
||||
m_CorrespondingSourceObject: {fileID: 0} |
||||
m_PrefabInstance: {fileID: 0} |
||||
m_PrefabAsset: {fileID: 0} |
||||
m_GameObject: {fileID: 2037916656} |
||||
m_Enabled: 1 |
||||
m_CastShadows: 1 |
||||
m_ReceiveShadows: 1 |
||||
m_DynamicOccludee: 1 |
||||
m_StaticShadowCaster: 0 |
||||
m_MotionVectors: 1 |
||||
m_LightProbeUsage: 1 |
||||
m_ReflectionProbeUsage: 1 |
||||
m_RayTracingMode: 2 |
||||
m_RayTraceProcedural: 0 |
||||
m_RayTracingAccelStructBuildFlagsOverride: 0 |
||||
m_RayTracingAccelStructBuildFlags: 1 |
||||
m_SmallMeshCulling: 1 |
||||
m_RenderingLayerMask: 1 |
||||
m_RendererPriority: 0 |
||||
m_Materials: |
||||
- {fileID: 2100000, guid: 31321ba15b8f8eb4c954353edc038b1d, type: 2} |
||||
m_StaticBatchInfo: |
||||
firstSubMesh: 0 |
||||
subMeshCount: 0 |
||||
m_StaticBatchRoot: {fileID: 0} |
||||
m_ProbeAnchor: {fileID: 0} |
||||
m_LightProbeVolumeOverride: {fileID: 0} |
||||
m_ScaleInLightmap: 1 |
||||
m_ReceiveGI: 1 |
||||
m_PreserveUVs: 0 |
||||
m_IgnoreNormalsForChartDetection: 0 |
||||
m_ImportantGI: 0 |
||||
m_StitchLightmapSeams: 1 |
||||
m_SelectedEditorRenderState: 3 |
||||
m_MinimumChartSize: 4 |
||||
m_AutoUVMaxDistance: 0.5 |
||||
m_AutoUVMaxAngle: 89 |
||||
m_LightmapParameters: {fileID: 0} |
||||
m_SortingLayerID: 0 |
||||
m_SortingLayer: 0 |
||||
m_SortingOrder: 0 |
||||
m_AdditionalVertexStreams: {fileID: 0} |
||||
--- !u!33 &2037916659 |
||||
MeshFilter: |
||||
m_ObjectHideFlags: 0 |
||||
m_CorrespondingSourceObject: {fileID: 0} |
||||
m_PrefabInstance: {fileID: 0} |
||||
m_PrefabAsset: {fileID: 0} |
||||
m_GameObject: {fileID: 2037916656} |
||||
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} |
||||
--- !u!4 &2037916660 |
||||
Transform: |
||||
m_ObjectHideFlags: 0 |
||||
m_CorrespondingSourceObject: {fileID: 0} |
||||
m_PrefabInstance: {fileID: 0} |
||||
m_PrefabAsset: {fileID: 0} |
||||
m_GameObject: {fileID: 2037916656} |
||||
serializedVersion: 2 |
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} |
||||
m_LocalPosition: {x: 0, y: 2.084, z: 2.399} |
||||
m_LocalScale: {x: 1, y: 1, z: 1} |
||||
m_ConstrainProportionsScale: 0 |
||||
m_Children: [] |
||||
m_Father: {fileID: 0} |
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} |
||||
--- !u!1660057539 &9223372036854775807 |
||||
SceneRoots: |
||||
m_ObjectHideFlags: 0 |
||||
m_Roots: |
||||
- {fileID: 65465575} |
||||
- {fileID: 79651672} |
||||
- {fileID: 1887936864} |
||||
- {fileID: 2037916660} |
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 5db3399e186fb594b94c0b7480d102a3 |
||||
DefaultImporter: |
||||
externalObjects: {} |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -0,0 +1,18 @@
|
||||
using UnityEngine; |
||||
|
||||
namespace Tools.EasyPoolKit.Demo |
||||
{ |
||||
public class SimpleGOPoolManager : MonoBehaviour |
||||
{ |
||||
public GameObject prefab; |
||||
private void Start() |
||||
{ |
||||
var config = new RecyclablePoolConfig(); |
||||
config.SpawnFunc = () => Instantiate(prefab); |
||||
config.ObjectType = RecycleObjectType.GameObject; |
||||
config.ExtraArgs = new object[] { transform }; |
||||
config.InitCreateCount = 5; |
||||
var pool = new SimpleGameObjectPool(config); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2 |
||||
guid: c53679ae49565704d8a17892b9bbc378 |
Before Width: | Height: | Size: 5.4 KiB After Width: | Height: | Size: 5.4 KiB |
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 3.3 KiB |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue