Abstract
ํฌํผ๋ ํ๋ ์์ํฌ ์ฝ๋๋ฅผ ๊ณ ์น์ง ์๊ณ ๋์์ ๋ฐ๊พธ๋ ์์ก์ด์
๋๋ค. "๋ก๊ทธ๋ฅผ ํ์ผ์๋ ๋จ๊ธฐ๊ณ ์ถ๋ค", "์ํฐํฐ๋ฅผ ๋ค๋ฅธ ๋ฐฉ์์ผ๋ก ์ธ์คํด์คํํ๊ณ ์ถ๋ค" ๊ฐ์ ์๊ตฌ๊ฐ ์๊ธฐ๋ฉด ํ๋ ์์ํฌ ์์ค๋ฅผ ์ฌ๋ ๋์ ํฌํผ ํด๋์ค๋ฅผ ํ๋ ๋ง๋ค์ด ๊ฐ์ ๋ผ์๋๋ค.
์ธ์ ์ฐ๋
โข
ํ๋ซํผ๋ง๋ค ๊ตฌํ์ด ๋ฌ๋ผ์ผ ํ๋ ๋ถ๋ถ (๋ก๊ทธ, ์์ถ, JSON)
โข
ํ๋ ์์ํฌ์ ๊ธฐ๋ณธ ๋์์ด ๋ด ๊ฒ์๊ณผ ๋ง์ง ์๋ ๋ถ๋ถ (UI ์ ๋ ฌ ๋ฐฉ์, ์ฌ์ด๋ ์์ด์ ํธ)
โข
ํ๋ ์์ํฌ๋ฅผ ์
๋ฐ์ดํธํด๋ ๋ด ์์ ์ด ๋ ์๊ฐ์ง ์๊ฒ ํ๊ณ ์ถ์ ๋
์ง์ ํด ๋ณด๊ธฐ โ ๋ก๊ทธ์ ์๊ฐ ๋ถ์ด๊ธฐ
using GameFramework;
using UnityEngine;
namespace MyGame
{
public class TimestampLogHelper : GameFrameworkLog.ILogHelper
{
public void Log(GameFrameworkLogLevel level, object message)
{
string line = Utility.Text.Format("[{0:F2}] {1}", Time.realtimeSinceStartup, message);
switch (level)
{
case GameFrameworkLogLevel.Warning: Debug.LogWarning(line); break;
case GameFrameworkLogLevel.Error: Debug.LogError(line); break;
default: Debug.Log(line); break;
}
}
}
}
C#
๋ณต์ฌ
GameFramework.prefab ๋ฃจํธ์ BaseComponent ์์ Log Helper Type Name ์ MyGame.TimestampLogHelper ๋ก ๋ฐ๊พธ๋ฉด ๋์
๋๋ค. ๋ค์์คํ์ด์ค๊น์ง ํฌํจํ ์ ์ฒด ํ์
์ด๋ฆ์ ์ ์ต๋๋ค. ์ดํ Log.Info(...) ๋ฅผ ๋ถ๋ฅด๋ ๋ชจ๋ ์ฝ๋๊ฐ ์ ํฌํผ๋ฅผ ๊ฑฐ์นฉ๋๋ค.
ToyboxNightmare ์์ ํฌํผ๊ฐ ํ์ํ๋ ์ง์
๊ธฐ๋ณธ UI ๊ทธ๋ฃน ํฌํผ(DefaultUIGroupHelper)์ SetDepth ๋ ๋น ๊ตฌํ์
๋๋ค. ๊ทธ๋์ UI ๊ทธ๋ฃน์ depth ๊ฐ์ ๋ฐ๊ฟ๋ ํ๋ฉด ์์๊ฐ ๋ฐ๋์ง ์์ต๋๋ค. ์์ ๋ ๊ฐ ํผ Canvas ์ Sorting Order ๋ก ์์๋ฅผ ์ ํ์ง๋ง(HUD 0, ์ผ์์ ์ง 100), ๊ทธ๋ฃน depth ๋ก ์ ์ดํ๊ณ ์ถ๋ค๋ฉด UIGroupHelperBase ๋ฅผ ์์ํด SetDepth(int depth) ๋ฅผ ๊ตฌํํ ํฌํผ๋ฅผ ๋ง๋ค๋ฉด ๋ฉ๋๋ค. ํ๋ ์์ํฌ๊ฐ "๊ธฐ๋ณธ๊ฐ์ ์ฃผ๋ ์ ์ฑ
์ ๊ฐ์ํ์ง ์๋๋ค"๋ ๊ฒ์ ๋ณด์ฌ ์ฃผ๋ ์์
๋๋ค.
์ด ์๋์
์์ ๋ค๋ฅธ ์ : ์๋ ๋ณธ๋ฌธ์ ์ธ์คํํฐ์ ๋๋กญ๋ค์ด์ผ๋ก ํฌํผ๋ฅผ ๊ณ ๋ฅธ๋ค๊ณ ์ค๋ช
ํฉ๋๋ค(BaseComponentInspector, HelperInfo). ๊ทธ ์๋ํฐ ํ์ฅ์ ์ด ์๋์
์ ๋ค์ด ์์ง ์์ต๋๋ค. ๋์ ์ธ์คํํฐ์ ๋ณด์ด๋ ... Helper Type Name ๋ฌธ์์ด ํ๋์ ํ์
์ด๋ฆ์ ์ง์ ์
๋ ฅํฉ๋๋ค. ๋์์ ๊ฐ์ต๋๋ค. ๋ณธ๋ฌธ์์ "Diagram: ..." ์ด๋ผ๊ณ ๋ง ์ ํ๊ณ ๊ทธ๋ฆผ์ด ์๋ ๊ณณ์ ์๋ณธ ๋ค์ด์ด๊ทธ๋จ์ด ๋๋ฝ๋ ์๋ฆฌ์
๋๋ค.
Helper Pattern
๊ด๋ จ ์์ค ํ์ผ
โข
Scripts/Editor/Inspector/BaseComponentInspector.cs
โข
Scripts/Editor/Inspector/ProcedureComponentInspector.cs
โข
Scripts/Editor/Misc/HelperInfo.cs
โข
Scripts/Editor/Misc/Type.cs
โข
Scripts/Runtime/Sound/DefaultSoundAgentHelper.cs
โข
Scripts/Runtime/Sound/SoundAgentHelperBase.cs
โข
Scripts/Runtime/Utility/DefaultJsonHelper.cs
โข
Scripts/Runtime/Utility/DefaultJsonHelper.cs.meta
โข
Scripts/Runtime/Utility/DefaultLogHelper.cs.meta
โข
Scripts/Runtime/Utility/DefaultVersionHelper.cs
โข
Scripts/Runtime/Utility/Log.cs.meta
Unity Game Framework ์ ๋ฐ์์ ์ฌ์ฉ๋๋ Helper Pattern์ ๋ค์ํ ์์คํ
๋์์ ์ปค์คํฐ๋ง์ด์ง๊ณผ ํ์ฅ์ ๊ฐ๋ฅํ๊ฒ ํ๋ ํต์ฌ ์ํคํ
์ฒ์ ์ ๊ทผ ๋ฐฉ์์
๋๋ค. ์ด ํจํด์ ๊ธฐ๋ฅ์ ์ ์ํ๋ ์ธํฐํ์ด์ค์ ๊ทธ ๊ธฐ๋ฅ์ ์ํํ๋ ๊ตฌ์ฒด์ ๊ตฌํ ์ฌ์ด์ ๋ช
ํํ ๋ถ๋ฆฌ๋ฅผ ๋ง๋ญ๋๋ค. ์ด ํจํด์ ์ฌ์ฉํจ์ผ๋ก์จ ํ๋ ์์ํฌ๋ ํฉ๋ฆฌ์ ์ธ ๊ธฐ๋ณธ ๊ตฌํ์ ์ ๊ณตํ๋ฉด์๋ ์ ์ฐ์ฑ์ ์ ์งํฉ๋๋ค.
ํ๋ ์์ํฌ ๋ด์์ ์ปดํฌ๋ํธ๊ฐ ์ด๋ป๊ฒ ๋ฑ๋ก๋๊ณ ๊ด๋ฆฌ๋๋์ง์ ๋ํ ์ ๋ณด๋ GameEntry and Component Management๋ฅผ ์ฐธ์กฐํ์ธ์.
Pattern Overview
Unity Game Framework์์ ๊ตฌํ๋ Helper Pattern์ ์ผ๊ด๋ ๊ตฌ์กฐ๋ฅผ ๋ฐ๋ฆ
๋๋ค:
โข
์ธํฐํ์ด์ค ๋๋ ์ถ์ ๊ธฐ๋ณธ ํด๋์ค๊ฐ ํ์ํ ๊ธฐ๋ฅ์ ์ ์ํ๋ค.
โข
๊ณตํต ์ฌ์ฉ ์ฌ๋ก๋ฅผ ์ฒ๋ฆฌํ๋ ๊ธฐ๋ณธ ๊ตฌํ์ด ์ ๊ณต๋๋ค.
โข
์์คํ
์ ํ์ํ ๋ ๊ฐ๋ฐ์๊ฐ ์ปค์คํ
๊ตฌํ์ผ๋ก ๋์ฒดํ ์ ์๋๋ก ํ๋ค.
์ด ํจํด์ ํ๋ซํผ๋ณ ๊ตฌํ์ด ํ์ํ ์ ์๋ ๊ธฐ๋ฅ์ด๋, ๊ฐ๋ฐ์๊ฐ ์ปค์คํ
๋์์ผ๋ก ํ์ฅํ๊ณ ์ถ์ดํ ์ ์๋ ๊ธฐ๋ฅ์ ํนํ ์ค์ํฉ๋๋ค.
Diagram: Helper Pattern Class Structure
์ถ์ฒ:
Scripts/Runtime/Sound/SoundAgentHelperBase.cs 1-189
Scripts/Runtime/Sound/DefaultSoundAgentHelper.cs 1-435
Helper Registration and Management
ํ๋ ์์ํฌ๋ ์ปดํฌ๋ํธ ์ธ์คํํฐ๋ฅผ ํตํด ํฌํผ๋ฅผ ๊ด๋ฆฌํ์ฌ, ๊ฐ๋ฐ์๊ฐ ๊ธฐ๋ณธ ๊ตฌํ๊ณผ ์ปค์คํ
๊ตฌํ ์ค์์ ์ ํํ ์ ์๋๋ก ํฉ๋๋ค. ์ด ์ค์ ์ ์ผ๋ฐ์ ์ผ๋ก Unity ์๋ํฐ์์ ์ํ๋ฉ๋๋ค.
Diagram: Helper Selection and Registration Flow
์ถ์ฒ:
Scripts/Editor/Inspector/BaseComponentInspector.cs 46-170
Global Helpers
BaseComponent๋ ํ๋ ์์ํฌ ์ ๋ฐ์์ ๊ธฐ๋ณธ์ ์ธ ๊ธฐ๋ฅ์ ์ ๊ณตํ๋ ์ฌ๋ฌ ์ฝ์ด ํฌํผ๋ค์ ๊ด๋ฆฌํฉ๋๋ค:
โข
Text Helper โ ํ
์คํธ ์ฒ๋ฆฌ ์ ํธ๋ฆฌํฐ
โข
Version Helper โ ๋ฒ์ ์ ๋ณด์ ๋น๊ต
โข
Log Helper โ ๋ก๊น
๊ธฐ๋ฅ
โข
Compression Helper โ ๋ฐ์ดํฐ ์์ถ ๋ฐ ํด์
โข
JSON Helper โ JSON ์ง๋ ฌํ ๋ฐ ์ญ์ง๋ ฌํ
์ด ํฌํผ๋ค์ BaseComponent ์ธ์คํํฐ์์ ์ค์ ํ ์ ์์ผ๋ฉฐ, ๊ฐ๋ฐ์๋ ๊ธฐ๋ณธ ๊ตฌํ์ ์ ํํ๊ฑฐ๋ ์ปค์คํ
๊ตฌํ์ ์ ๊ณตํ ์ ์์ต๋๋ค.
Diagram: Global Helpers in BaseComponent
์ถ์ฒ:
Scripts/Editor/Inspector/BaseComponentInspector.cs 64-103
Scripts/Runtime/Utility/DefaultVersionHelper.cs 1-41
Scripts/Runtime/Utility/DefaultJsonHelper.cs 1-52
Helper Selection in Inspector
Unity ์๋ํฐ๋ ๊ฐ ์ปดํฌ๋ํธ์ ๋ํ ํฌํผ๋ฅผ ์ ํํ๊ณ ๊ตฌ์ฑํ ์ ์๋ ์ปค์คํ
์ธํฐํ์ด์ค๋ฅผ ์ ๊ณตํฉ๋๋ค. ์ด๋ฅผ ํตํด ๊ฐ๋ฐ์๋ ๊ธฐ๋ณธ ๊ตฌํ์ ์ ํํ๊ฑฐ๋ ์ง์ ๋ง๋ ์ปค์คํ
ํฌํผ๋ฅผ ์ง์ ํ ์ ์์ต๋๋ค.
BaseComponentInspector๋ ๊ธ๋ก๋ฒ ํฌํผ๋ฅผ ์ํ ์ด UI๋ฅผ ๊ตฌํํฉ๋๋ค:
1.
TextHelper ์ ํ ๋๋กญ๋ค์ด
2.
VersionHelper ์ ํ ๋๋กญ๋ค์ด
3.
LogHelper ์ ํ ๋๋กญ๋ค์ด
4.
CompressionHelper ์ ํ ๋๋กญ๋ค์ด
5.
JsonHelper ์ ํ ๋๋กญ๋ค์ด
๊ฐ ๋๋กญ๋ค์ด์ ํ๋ก์ ํธ ์ด์
๋ธ๋ฆฌ์์ ๋ฐ๊ฒฌ๋ ์ฌ์ฉ ๊ฐ๋ฅํ ํฌํผ ๊ตฌํ๋ค๋ก ์ฑ์์ง๋๋ค.
์ถ์ฒ:
Scripts/Editor/Inspector/BaseComponentInspector.cs 64-103
Helper Implementation Discovery
ํ๋ ์์ํฌ๋ ๋ฐํ์์ ์ฌ์ฉ ๊ฐ๋ฅํ ํฌํผ ๊ตฌํ์ ์ฐพ๊ธฐ ์ํด ๋ฆฌํ๋ ์
์ ์ฌ์ฉํฉ๋๋ค. Type.GetRuntimeTypeNames() ๋ฉ์๋๋ ํน์ ํฌํผ ์ธํฐํ์ด์ค๋ฅผ ๊ตฌํํ๋ ํด๋์ค๋ฅผ ์ง์ ๋ ์ด์
๋ธ๋ฆฌ์์ ๊ฒ์ํฉ๋๋ค.
Diagram: Helper Implementation Discovery Process
์ถ์ฒ:
Scripts/Editor/Misc/Type.cs 78-91
Scripts/Editor/Misc/Type.cs 93-125
Example: Sound Agent Helper
ํ๋ ์์ํฌ์์ Helper Pattern์ ๊ตฌ์ฒด์ ์ธ ์์๋ ์ค๋์ค ์ฌ์์ ๋ค๋ฃจ๋ Sound Agent Helper ์์คํ
์
๋๋ค.
Diagram: Sound Agent Helper Class Hierarchy
์ถ์ฒ:
Scripts/Runtime/Sound/SoundAgentHelperBase.cs 1-189
Scripts/Runtime/Sound/DefaultSoundAgentHelper.cs 1-435
Creating Custom Helpers
์ปค์คํ
ํฌํผ๋ฅผ ๋ง๋ค๋ ค๋ฉด:
1.
์ ์ ํ ํฌํผ ์ธํฐํ์ด์ค๋ฅผ ๊ตฌํํ๊ฑฐ๋ ํฌํผ ๊ธฐ๋ณธ ํด๋์ค๋ฅผ ์์ํ๋ค.
2.
๊ตฌํ์ ์ ์ ํ Unity ์ด์
๋ธ๋ฆฌ์ ์ถ๊ฐํ๋ค.
3.
์ธ์คํํฐ๋ฅผ ํตํด ์ปดํฌ๋ํธ๋ฅผ ์ค์ ํ์ฌ ์ปค์คํ
ํฌํผ๋ฅผ ์ฌ์ฉํ๋ค.
์: ์ปค์คํ
JSON ํฌํผ๋ฅผ ๋ง๋ค๋ ค๋ฉด:
โข
Utility.Json.IJsonHelper๋ฅผ ๊ตฌํํ๋ ํด๋์ค๋ฅผ ๋ง๋ ๋ค.
โข
ํ์ํ ๋ฉ์๋(ToJson, ToObject<T> ๋ฑ)๋ฅผ ๊ตฌํํ๋ค.
โข
BaseComponent ์ธ์คํํฐ์์ ์ปค์คํ
๊ตฌํ์ ์ ํํ๋ค.
Component-Specific Helpers
BaseComponent๊ฐ ๊ด๋ฆฌํ๋ ๊ธ๋ก๋ฒ ํฌํผ ์ธ์๋, ๋ง์ ํ๋ ์์ํฌ ์ปดํฌ๋ํธ๋ค์ ๊ฐ๊ฐ ๊ณ ์ ํ ํฌํผ๋ฅผ ๊ฐ์ง๊ณ ์์ต๋๋ค. ์์:
โข
Sound ์ปดํฌ๋ํธ๋ SoundAgentHelper ์ฌ์ฉ
โข
Resource ์ปดํฌ๋ํธ๋ ResourceHelper์ LoadResourceAgentHelper ์ฌ์ฉ
โข
Web Request ์ปดํฌ๋ํธ๋ WebRequestAgentHelper ์ฌ์ฉ
โข
File System ์ปดํฌ๋ํธ๋ FileSystemHelper ์ฌ์ฉ
๊ฐ๊ฐ์ ๊ธฐ๋ณธ ๊ตฌํ์ ์ ๊ณตํ๋ฉด์ ์ปค์คํ
๊ต์ฒด๋ ๊ฐ๋ฅํ๊ฒ ๋์ผํ ํจํด์ ๋ฐ๋ฆ
๋๋ค.
Helper Selection Implementation
ํ๋ ์์ํฌ๋ ์ธ์คํํฐ์์ ํฌํผ๋ฅผ ํ์ํ๊ณ ์ ํํ๋ ๊ณผ์ ์ ๋จ์ํํ๊ธฐ ์ํด ์ ํธ๋ฆฌํฐ ํด๋์ค๋ฅผ ์ ๊ณตํฉ๋๋ค.
Diagram: Helper Info Class Used in Inspectors
์ถ์ฒ:
Scripts/Editor/Misc/HelperInfo.cs 1-98
HelperInfo<T> ํด๋์ค๋ ์ธ์คํํฐ UI๋ฅผ ์ฒ๋ฆฌํ์ฌ, ํฌํผ ๊ตฌํ๋ค ์ค์์ ์ ํํ ์ ์๋ ๋๋กญ๋ค์ด ๋ฉ๋ด์ ํ์ํ ๊ฒฝ์ฐ ์ปค์คํ
ํฌํผ ํ๋๋ฅผ ํ์ํฉ๋๋ค.
Default Helper Implementations
ํ๋ ์์ํฌ๋ ํ์ํ ๋ชจ๋ ํฌํผ์ ๊ธฐ๋ณธ ๊ตฌํ์ ์ ๊ณตํฉ๋๋ค. ์ด ๊ตฌํ๋ค์ ๋๋ถ๋ถ์ ๊ณตํต ์ฌ์ฉ ์ฌ๋ก์์ ์๋ํ๋ ๊ธฐ๋ณธ ๊ธฐ๋ฅ์ ์ ๊ณตํฉ๋๋ค.
Default Version Helper
DefaultVersionHelper๋ Unity Application์ ๋ฒ์ ์ ๊ธฐ๋ฐ์ผ๋ก ๋ฒ์ ์ ๋ณด๋ฅผ ์ ๊ณตํฉ๋๋ค:
โข
๊ฒ์ ๋ฒ์ ์ Application.version ๋ฐํ
โข
๋ด๋ถ ๊ฒ์ ๋ฒ์ ์ 0 ๋ฐํ
์ถ์ฒ:
Scripts/Runtime/Utility/DefaultVersionHelper.cs 1-41
Default JSON Helper
DefaultJsonHelper๋ Unity์ ๋ด์ฅ JsonUtility๋ฅผ ์ฌ์ฉํ์ฌ JSON ์ง๋ ฌํ/์ญ์ง๋ ฌํ๋ฅผ ์ํํฉ๋๋ค:
โข
์ง๋ ฌํ์๋ JsonUtility.ToJson ์ฌ์ฉ
โข
์ญ์ง๋ ฌํ์๋ JsonUtility.FromJson ์ฌ์ฉ
์ถ์ฒ:
Scripts/Runtime/Utility/DefaultJsonHelper.cs 1-52
Summary
Helper Pattern์ Unity Game Framework์์ ์์คํ
๋์์ ์ปค์คํฐ๋ง์ด์ง๊ณผ ํ์ฅ์ ๊ฐ๋ฅํ๊ฒ ํ๋ ๊ทผ๋ณธ์ ์ธ ์ํคํ
์ฒ ์ ๊ทผ ๋ฐฉ์์
๋๋ค. ์ธํฐํ์ด์ค์ ๊ตฌํ์ ๋ถ๋ฆฌํ๊ณ , ๊ธฐ๋ณธ ๋ฐ ์ปค์คํ
์ต์
๋ชจ๋๋ฅผ ์ ๊ณตํจ์ผ๋ก์จ ํ๋ ์์ํฌ๋ ์ฌ์ฉ์ ์ฉ์ด์ฑ๊ณผ ์ ์ฐ์ฑ ์ฌ์ด์ ๊ท ํ์ ๋ฌ์ฑํฉ๋๋ค.
Helper Pattern์ ์ฃผ์ ์ด์ ์ ๋ค์๊ณผ ๊ฐ์ต๋๋ค:
โข
์ผ๋ฐ์ ์ธ ์ฌ์ฉ ์ฌ๋ก๋ฅผ ์ํ ํฉ๋ฆฌ์ ์ธ ๊ธฐ๋ณธ๊ฐ ์ ๊ณต
โข
ํ๋ซํผ๋ณ ์๊ตฌ ์ฌํญ์ ๋ํ ์ปค์คํฐ๋ง์ด์ง ํ์ฉ
โข
ํน์ ๊ธฐ๋ฅ์ผ๋ก์ ํ์ฅ ๊ฐ๋ฅ
โข
์์กด์ฑ ์ฃผ์
์ ํตํ ํ
์คํธ ์ฉ์ด์ฑ ์ ๊ณต
โข
๊ด์ฌ์ฌ์ ๋ช
ํํ ๋ถ๋ฆฌ ์์ฑ
์ด ํจํด์ ํ๋ ์์ํฌ ์ ๋ฐ์์ ์ผ๊ด๋๊ฒ ์ฌ์ฉ๋๋ฉฐ, ์์คํ
์ปค์คํฐ๋ง์ด์ง์ ์ํ ํต์ผ๋ ์ ๊ทผ ๋ฐฉ์์ ํ์ฑํฉ๋๋ค.







