ComponentList 개발 중
This commit is contained in:
@@ -163,18 +163,20 @@ namespace UVC.Pool
|
||||
}
|
||||
}
|
||||
|
||||
if (_recycledItems.Count > 0)
|
||||
while (_recycledItems.Count > 0)
|
||||
{
|
||||
item = _recycledItems[0];
|
||||
item = _recycledItems[0]; //부모가 삭제 되면 null이 될 수 있습니다.
|
||||
_recycledItems.RemoveAt(0);
|
||||
if (item != null) break; // 유효한 아이템을 찾았으므로 루프를 종료합니다.
|
||||
// item이 null이면, 해당 아이템은 파괴된 것으로 간주하고 다음 아이템을 확인합니다.
|
||||
}
|
||||
else
|
||||
|
||||
if (item == null)
|
||||
{
|
||||
lock (_statsLock)
|
||||
{
|
||||
_poolMisses++;
|
||||
}
|
||||
|
||||
GameObject go = UnityEngine.Object.Instantiate(_originalPrefab);
|
||||
item = go.GetComponent<T>();
|
||||
}
|
||||
|
||||
@@ -176,13 +176,16 @@ namespace UVC.Pool
|
||||
}
|
||||
}
|
||||
|
||||
if (_recycledItems.Count > 0)
|
||||
while (_recycledItems.Count > 0)
|
||||
{
|
||||
// 재활용 목록에 아이템이 있으면 가져와서 사용합니다.
|
||||
item = _recycledItems[0];
|
||||
item = _recycledItems[0]; //부모가 삭제 되면 null이 될 수 있습니다.
|
||||
_recycledItems.RemoveAt(0);
|
||||
if (item != null) break; // 유효한 아이템을 찾았으므로 루프를 종료합니다.
|
||||
// item이 null이면, 해당 아이템은 파괴된 것으로 간주하고 다음 아이템을 확인합니다.
|
||||
}
|
||||
else
|
||||
|
||||
if (item == null)
|
||||
{
|
||||
// 재활용 목록이 비어있으면 새로 생성합니다.
|
||||
lock (_statsLock)
|
||||
|
||||
Reference in New Issue
Block a user