Abstract
ํ๋ง์ "๋ง๋ค๊ณ ๋ฒ๋ฆฌ๋ ๋์ ๋๋ ค ์ด๋ค"๋ ํ ๊ฐ์ง ์์ด๋์ด์
๋๋ค. ํ๋ ์์ํฌ์๋ ํ์ด ์ธ ๊ฒน์ผ๋ก ๋ค์ด ์๊ณ , ๊ทธ์ค ๊ฒ์ ์ฝ๋๊ฐ ์ง์ ๋ง์ง ์ผ์ด ์๋ ๊ฒ์ ์ฌ์ค์ ํ๋(๋ ํผ๋ฐ์ค ํ)์
๋๋ค. ๋๋จธ์ง๋ ์ํฐํฐ์ UI ๋ฅผ ์ฐ๋ฉด ์ ์ ๋ก ๋๋๋ค.
์ธ ๊ฒน์ ํ โ ๋ฌด์์ด ๋ฌด์์ ์ฌ์ฌ์ฉํ๋
ํ | ์ฌ์ฌ์ฉํ๋ ๊ฒ | ๊ฒ์ ์ฝ๋๊ฐ ํ๋ ์ผ | ToyboxNightmare |
์ํฐํฐ ๊ทธ๋ฃน / UI ๊ทธ๋ฃน
(๋ด๋ถ์ ์ผ๋ก ์ค๋ธ์ ํธ ํ) | ํ๋ฆฌํน ์ธ์คํด์ค(GameObject) | ShowEntity / HideEntity ๋ง ๋ถ๋ฅธ๋ค. ํ์ ๋ณด์ด์ง ์๋๋ค | ์ ยทํฌ์ฌ์ฒดยท์ดํํธ ์ ๋ถ |
์ค๋ธ์ ํธ ํ
(ObjectPoolComponent) | ์ํฐํฐ๋ UI ํผ๋ ์๋ ๊ฒ โ ์๋ HP ๋ฐ, ๋ฐ๋ฏธ์ง ์ซ์ ๋ฑ | ํ์ ์ง์ ๋ง๋ค๊ณ Spawn / Unspawn | ์ง์ ์ฐ์ง ์์ |
๋ ํผ๋ฐ์ค ํ
(ReferencePool) | ์์ C# ๊ฐ์ฒด โ ์ด๋ฒคํธ ์ธ์, ์ํฐํฐ ๋ฐ์ดํฐ | Acquire / Release | ์ด๋ฒคํธ ์ธ์ 7์ข
, ์ํฐํฐ ๋ฐ์ดํฐ 7์ข
|
๊ณ ๋ฅด๋ ๊ธฐ์ค
โข
๊ฒ์ ์๋์ ๋ํ๋ฌ๋ค ์ฌ๋ผ์ง๋ ๊ฒ โ ์ํฐํฐ๋ก ๋ง๋ ๋ค. ํ๋ง์ ๋ฐ๋ผ์จ๋ค.
โข
ํ๋ฉด์ ๋จ๋ ์ฐฝ โ UI ํผ์ผ๋ก ๋ง๋ ๋ค. ๋ง์ฐฌ๊ฐ์ง.
โข
์ ๋์ ์ ๋ง๋๋ฐ ์์ฃผ ์๊ธฐ๋ GameObject โ ์ค๋ธ์ ํธ ํ.
โข
new ๋ก ์์ฃผ ๋ง๋๋ ์์ ํด๋์ค โ ๋ ํผ๋ฐ์ค ํ.
ํ ํฌ๊ธฐ๋ ์ด๋์ ์ ํ๋
์ํฐํฐ ๊ทธ๋ฃน์ ํ ์ค์ ์ GameFramework.prefab ์ Entity ์ค๋ธ์ ํธ์ ์์ต๋๋ค. ์์ ์ ๊ฐ์
๋๋ค.
๊ทธ๋ฃน | Instance Capacity | ๋ค์ด๊ฐ๋ ๊ฒ |
Player | 4 | ์ ํ ํ๋ฉด์ Girl / Boy, ํ๋ ์ด ์ค์ธ ์บ๋ฆญํฐ |
Enemy | 64 | ์ 5์ข
(์คํฐ ํ
์ด๋ธ์ ๋์ ์์กด ์ํ ํฉ๊ณ๋ 13) |
Projectile | 64 | ์ฌ๋ผ์ยท์
์ทจ ํฌ์ฌ์ฒด |
Effect | 32 | ํผ๊ฒฉ ์ดํํธ |
Ally | 2 | ์ํ๋ ์๊ตฐ (Sheep / Dog) |
Capacity ๋ "ํ์ ๋ณด๊ดํด ๋ ์ต๋ ์"์ด์ง ์คํฐ ์ํ์ด ์๋๋๋ค. ๋์ณ๋ ์คํฐ์ ๋๊ณ , ๋์น ๋งํผ์ ํ์๋ ๋ ๋ณด๊ด๋์ง ์๊ณ ํ๊ดด๋ ๋ฟ์
๋๋ค. Expire Time(์์ 60์ด) ๋์ ๋ค์ ์ฐ์ด์ง ์์ ์ธ์คํด์ค๋ Auto Release Interval(60์ด)๋ง๋ค ๋๋ ๊ฒ์ฌ์์ ์ ๋ฆฌ๋ฉ๋๋ค.
๋ณธ๋ฌธ์ ์ฝ์ ๋ ์ฃผ์ํ ์
โข
๋ณธ๋ฌธ์ ์ค๋ธ์ ํธ ํ์ "Unity GameObject ์ ์ฉ"์ด๋ผ๊ณ ์ค๋ช
ํ์ง๋ง, ์ ํํ๋ ObjectBase ๋ก ๊ฐ์ผ ์์์ ๊ฐ์ฒด๋ฅผ ๋ค๋ฃน๋๋ค. ์์์ ๋ก๋ํ ์์
์์ฒด๋ ์ด ํ๋ก ๊ด๋ฆฌํ์ต๋๋ค. GameObject ํ๋ง์ ๊ฐ์ฅ ํํ ์ฉ๋์ผ ๋ฟ์
๋๋ค.
โข
"Editor Integration" ์ (์ธ์คํํฐ์์ ํต๊ณ ๋ณด๊ธฐ, CSV ๋ด๋ณด๋ด๊ธฐ, ์๋ ํด์ )์ ์ด ์๋์
์ ์์ต๋๋ค. ์๋ํฐ ํ์ฅ์ด ๋น ์ ธ ์์ต๋๋ค. ๊ฐ์ ์ ๋ณด๋ ๋ฐํ์ Debugger ์ฐฝ์ Object Pool / Reference Pool ํญ์์ ๋ด
๋๋ค.
Pooling Systems (ํ๋ง ์์คํ )
Relevant source files (๊ด๋ จ ์์ค ํ์ผ)
โข
Scripts/Editor/Inspector/ObjectPoolComponentInspector.cs
โข
Scripts/Editor/Inspector/ReferencePoolComponentInspector.cs
โข
Scripts/Editor/Inspector/ReferencePoolComponentInspector.cs.meta
โข
Scripts/Runtime/Debugger/DebuggerActiveWindowType.cs
โข
Scripts/Runtime/Debugger/DebuggerComponent.ObjectPoolInformationWindow.cs
โข
Scripts/Runtime/Debugger/DebuggerComponent.ReferencePoolInformationWindow.cs
โข
Scripts/Runtime/Debugger/DebuggerComponent.ReferencePoolInformationWindow.cs.meta
โข
Scripts/Runtime/Debugger/DebuggerComponent.RuntimeMemoryInformationWindow.cs
โข
Scripts/Runtime/Debugger/DebuggerComponent.RuntimeMemorySummaryWindow.cs
โข
Scripts/Runtime/Debugger/DebuggerComponent.cs
โข
Scripts/Runtime/ReferencePool.meta
โข
Scripts/Runtime/ReferencePool/ReferencePoolComponent.cs
โข
Scripts/Runtime/ReferencePool/ReferencePoolComponent.cs.meta
โข
Scripts/Runtime/ReferencePool/ReferenceStrictCheckType.cs
โข
Scripts/Runtime/ReferencePool/ReferenceStrictCheckType.cs.meta
Overview (๊ฐ์)
Unity Game Framework๋ ๊ฒ์ ๋ด ๋ฉ๋ชจ๋ฆฌ ์ฌ์ฉ ์ต์ ํ ๋ฐ GC(Garbage Collection) ๋ถํ ๊ฐ์๋ฅผ ์ํด ๋ ๊ฐ์ง ํ๋ง ์์คํ
์ ์ ๊ณตํฉ๋๋ค.
โข
Object Pool System (์ค๋ธ์ ํธ ํ ์์คํ
): Unity GameObject ์ ์ฉ ํ๋ง
โข
Reference Pool System (๋ ํผ๋ฐ์ค ํ ์์คํ
): C# ๊ฐ์ฒด ์ ์ฉ ํ๋ง
์ด ๋ ์์คํ
์ ๊ฐ์ฒด๋ฅผ ์ฌ์ฌ์ฉํจ์ผ๋ก์จ ์ฑ๋ฅ์ ๊ฐ์ ํ๋ฉฐ, ๋ฐ๋ณต์ ์ธ ์์ฑ/ํ๊ดด๋ก ์ธํ ์ค๋ฒํค๋๋ฅผ ์ค์
๋๋ค.
์ผ๋ฐ์ ์ธ ๋ฆฌ์์ค ๊ด๋ฆฌ์ ๋ํด์๋ Resource Management System ์ฐธ๊ณ
Sources:
Scripts/Runtime/ReferencePool/ReferencePoolComponent.cs
Scripts/Runtime/ObjectPool/ObjectPoolComponent.cs (ํ์ผ ๋ชฉ๋ก์๋ ์์ง๋ง ์ถ๋ก ๋จ)
Scripts/Runtime/Debugger/DebuggerComponent.ObjectPoolInformationWindow.cs
Scripts/Runtime/Debugger/DebuggerComponent.ReferencePoolInformationWindow.cs
Object Pool System (์ค๋ธ์ ํธ ํ ์์คํ )
์ค๋ธ์ ํธ ํ ์์คํ
์ Unity GameObject๋ฅผ ๊ด๋ฆฌํฉ๋๋ค.
๊ฐ์ฒด๋ฅผ ๋งค๋ฒ Instantiate/Destroy ํ์ง ์๊ณ ์ฌ์ฌ์ฉํ ์ ์๋๋ก ํ์ฌ, ํนํ ํฌ์ฌ์ฒด, ์ดํํธ, UI ์์ ๋ฑ ์์ฃผ ์์ฑ/ํ๊ดด๋๋ ์ค๋ธ์ ํธ์ ์ ๋ฆฌํฉ๋๋ค.
Architecture and Components (์ํคํ ์ฒ ๋ฐ ์ปดํฌ๋ํธ)
Sources:
Scripts/Editor/Inspector/ObjectPoolComponentInspector.cs 41-45
Scripts/Editor/Inspector/ObjectPoolComponentInspector.cs 75-82
Scripts/Editor/Inspector/ObjectPoolComponentInspector.cs 83-90
Scripts/Runtime/Debugger/DebuggerComponent.ObjectPoolInformationWindow.cs 46-58
Key Features (ํต์ฌ ๊ธฐ๋ฅ)
โข
Single/Multi-Spawn ์ง์:
ํ๋์ ์ธ์คํด์ค๋ง ๋์์ ํ์ฑํ๋๋ ๋จ์ผ ์คํฐ ๋ชจ๋์ ์ฌ๋ฌ ๊ฐ๋ฅผ ๋์์ ํ์ฑํํ ์ ์๋ ๋ฉํฐ ์คํฐ ๋ชจ๋ ์ง์
โข
์๋ ๋ฐํ(Auto-Release):
์ง์ ํ ์๊ฐ ํ ๊ฐ์ฒด๋ฅผ ํ๋ก ์๋ ๋ฐํ
โข
์ฐ์ ์์(Prioritization):
ํ ๊ณต๊ฐ์ด ๋ถ์กฑํ ๋ ์ฐ์ ์์๊ฐ ๋์ ๊ฐ์ฒด๋ ๋ ์ค๋ ์ ์ง๋จ
โข
๊ฐ์ฒด ์ถ์ (Object Tracking):
๊ฐ ๊ฐ์ฒด์ ์ํ์ ๋ง์ง๋ง ์ฌ์ฉ ์์ ๋ฑ ์์ธ ์ ๋ณด ์ถ์
Using the Object Pool (์ฌ์ฉ ๋ฐฉ๋ฒ)
โข
์ฃผ๋ก Prefab ์ธ์คํด์ค, ์์ฃผ ์์ฑ/์ญ์ ๋๋ Unity ์ค๋ธ์ ํธ ๊ด๋ฆฌ์ ์ฌ์ฉ
โข
๋ฐํ๋ ์ค๋ธ์ ํธ๋ ๋นํ์ฑํ ์ํ๋ก ์ ์ง๋๋ฉฐ, ํ์ํ ๋ ์ฆ์ ์ฌํ์ฑํ ๊ฐ๋ฅ
Reference Pool System (๋ ํผ๋ฐ์ค ํ ์์คํ )
๋ ํผ๋ฐ์ค ํ ์์คํ
์ C# ๊ฐ์ฒด๋ฅผ ๊ด๋ฆฌํ์ฌ GC ๋ถํ๋ฅผ ์ค์ด๋ ๊ฒ์ ์ด์ ์ด ๋ง์ถฐ์ ธ ์์ต๋๋ค.
ํนํ ์ด๋ฒคํธ ํ๋ผ๋ฏธํฐ, ์ปค๋งจ๋ ์ธ์, ์์ ๋ฐ์ดํฐ ๊ตฌ์กฐ์ฒด ๋ฑ ์งง์ ์๋ช
์ฃผ๊ธฐ ๊ฐ์ฒด์ ์ ์ฉํฉ๋๋ค.
Architecture and Components (์ํคํ ์ฒ ๋ฐ ์ปดํฌ๋ํธ)
Sources:
Scripts/Runtime/ReferencePool/ReferencePoolComponent.cs 16-72
Scripts/Runtime/ReferencePool/ReferenceStrictCheckType.cs 13-34
Scripts/Editor/Inspector/ReferencePoolComponentInspector.cs 48-58
Scripts/Runtime/Debugger/DebuggerComponent.ReferencePoolInformationWindow.cs 33-41
Strict Checking (์๊ฒฉ ๊ฒ์ฌ)
๋ ํผ๋ฐ์ค ํ์ ๊ฐ์ฒด๊ฐ ์ฌ๋ฐ๋ฅด๊ฒ ํ๋/๋ฐํ๋๋์ง ๊ฒ์ฌํ ์ ์๋ ๊ธฐ๋ฅ์ ์ ๊ณตํฉ๋๋ค.
โข
ํ์ฑํ ์, ๊ฐ์ฒด์ ์ฌ๋ฐ๋ฅธ ํ๋/๋ฐํ ์ฌ๋ถ๋ฅผ ๊ฒ์ฆ
โข
๋ฉ๋ชจ๋ฆฌ ๋์๋ ์๋ชป๋ ์ฌ์ฉ ํจํด์ ํ์ง ๊ฐ๋ฅ
โข
๊ฐ๋ฐ ์์ (์๋ํฐ/๋๋ฒ๊ทธ ๋น๋ ๋ฑ)์์๋ง ํ์ฑํ ๊ฐ๋ฅ
ReferenceStrictCheckType ์ต์
:
โข
AlwaysEnable: ํญ์ ํ์ฑํ
โข
OnlyEnableWhenDevelopment: ๊ฐ๋ฐ ๋น๋์์๋ง ํ์ฑํ
โข
OnlyEnableInEditor: ์๋ํฐ์์๋ง ํ์ฑํ
โข
AlwaysDisable: ๋นํ์ฑํ
Sources:
Scripts/Runtime/ReferencePool/ReferencePoolComponent.cs 51-69
Scripts/Runtime/ReferencePool/ReferenceStrictCheckType.cs 13-34
Using the Reference Pool (์ฌ์ฉ ๋ฐฉ๋ฒ)
โข
ํ๋ง ๋์ ํด๋์ค๋ IReference ์ธํฐํ์ด์ค๋ฅผ ๊ตฌํํ๊ณ public ๊ธฐ๋ณธ ์์ฑ์๋ฅผ ๊ฐ์ ธ์ผ ํจ
โข
๊ฐ์ฒด ํ๋: ReferencePool.Acquire<T>()
โข
๊ฐ์ฒด ๋ฐํ: ReferencePool.Release(reference) (์ ๋ค๋ฆญ์ด ์๋๋ฉฐ IReference ๋ฅผ ๋ฐ๋๋ค)
โข
์๊ฒฉ ๊ฒ์ฌ๋ ์ฑ๋ฅ์ ์ํฅ์ ์ค ์ ์์ผ๋ฏ๋ก ๋ณดํต ๊ฐ๋ฐ/ํ
์คํธ ์์๋ง ์ฌ์ฉ
Debugging and Monitoring (๋๋ฒ๊น ๋ฐ ๋ชจ๋ํฐ๋ง)
๋ ํ๋ง ์์คํ
๋ชจ๋ ๋๋ฒ๊ฑฐ ์ปดํฌ๋ํธ๋ฅผ ํตํด ๋ชจ๋ํฐ๋ง์ด ๊ฐ๋ฅํฉ๋๋ค.
Object Pool Information Window (์ค๋ธ์ ํธ ํ ์ ๋ณด ์ฐฝ)
ํ์ ๋ด์ฉ:
โข
์ ์ฒด ์ค๋ธ์ ํธ ํ ๊ฐ์
โข
๊ฐ ํ์ ์์ธ ์ ๋ณด: ์ด๋ฆ, ํ์
, ์ฉ๋
โข
ํ์ฌ ์ฌ์ฉ๋
โข
์๋ ๋ฐํ ๊ฐ๊ฒฉ
โข
์ฐ์ ์์ ์ค์
โข
๊ฐ์ฒด ์ํ ์ ๋ณด
Sources:
Scripts/Runtime/Debugger/DebuggerComponent.ObjectPoolInformationWindow.cs 30-92
Scripts/Editor/Inspector/ObjectPoolComponentInspector.cs 25-136
Reference Pool Information Window (๋ ํผ๋ฐ์ค ํ ์ ๋ณด ์ฐฝ)
ํ์ ๋ด์ฉ:
โข
์๊ฒฉ ๊ฒ์ฌ ํ์ฑ ์ฌ๋ถ
โข
์ ์ฒด ๋ ํผ๋ฐ์ค ํ ๊ฐ์
โข
๊ฐ ํ์
๋ณ ํต๊ณ:
โฆ
์ฌ์ฉ ์ค/๋ฏธ์ฌ์ฉ ๊ฐ์ฒด ์
โฆ
ํ๋/๋ฐํ ํ์
โฆ
์ถ๊ฐ/์ ๊ฑฐ ํ์
โข
ํด๋์ค ์ด๋ฆ ํ๊ธฐ๋ฅผ ์ ์ฒด ์ด๋ฆ / ๋จ์ ์ด๋ฆ์ผ๋ก ์ ํ ๊ฐ๋ฅ
Sources:
Scripts/Runtime/Debugger/DebuggerComponent.ReferencePoolInformationWindow.cs 30-86
Scripts/Editor/Inspector/ReferencePoolComponentInspector.cs 29-128
Editor Integration (์๋ํฐ ํตํฉ)
ํ๋ ์์ํฌ๋ ์๋ํฐ์์ ๋ค์ ๊ธฐ๋ฅ์ ์ ๊ณตํฉ๋๋ค:
โข
ํ ํต๊ณ ๋ชจ๋ํฐ๋ง (Play Mode ์ค ํ์ธ ๊ฐ๋ฅ)
โข
CSV๋ก ๋ฐ์ดํฐ ๋ด๋ณด๋ด๊ธฐ
โข
์ธ์คํํฐ์์ ์ง์ ๋ฏธ์ฌ์ฉ ๊ฐ์ฒด ํด์
Sources:
Scripts/Editor/Inspector/ObjectPoolComponentInspector.cs 20-138
Scripts/Editor/Inspector/ReferencePoolComponentInspector.cs 19-152
Best Practices (๋ชจ๋ฒ ์ฌ๋ก)
โข
Object Pool:
ํฌ์ฌ์ฒด, ์ดํํธ, UI ๋ฑ ์์ฃผ ์์ฑ/์ญ์ ๋๋ Unity GameObject ๊ด๋ฆฌ์ ์ฌ์ฉ
โข
Reference Pool:
์ด๋ฒคํธ ํ๋ผ๋ฏธํฐ, ๋ช
๋ น ์ธ์, ์์ ๋ฐ์ดํฐ ๋ฑ ์งง์ ์๋ช
์ C# ๊ฐ์ฒด ๊ด๋ฆฌ์ ์ฌ์ฉ
โข
์๋ ๋ฐํ ์ค์ :
๋ฉ๋ชจ๋ฆฌ ์ฌ์ฉ๊ณผ ์ฑ๋ฅ ๊ท ํ์ ๋ง์ถ ์ ์๋๋ก ์ ์ ํ ์ง์
โข
์ ์ ํ ์ฉ๋ ์ค์ :
๋์์ ํ์ํ ๊ฒ์ผ๋ก ์์๋๋ ์ต๋ ์๋๋ณด๋ค ์ฝ๊ฐ ํฐ ๊ฐ์ผ๋ก ํ ํฌ๊ธฐ ์ค์
โข
๊ฐ๋ฐ ์ค ์๊ฒฉ ๊ฒ์ฌ ํ์ฑํ:
๊ฐ๋ฐ ๋จ๊ณ์์๋ Reference Pool์ Strict Checking์ ์ผ์ ๋ฌธ์ ๋ฅผ ์กฐ๊ธฐ์ ๋ฐ๊ฒฌ,
๋ฆด๋ฆฌ์ฆ ๋น๋์์๋ ์ฑ๋ฅ์ ์ํด ๋นํ์ฑํ







