Game Framework
게임 제작을 수월하게 하기 위해 유니티에서 사용할 수 있는 프레임워크를 제작했습니다.
포함 된 기능:
Section titled “포함 된 기능:”- Config
- Popup / Scene Base Classes
- Time Management
- UIBinding using UniTaskPubSub
- Singleton Pattern
- Logging
- User-Friendly UnityWebRequest Wrapper
추천 기능:
Section titled “추천 기능:”- Quick Save: 메모리팩을 이용한 효율적인 데이터 물리 저장 / 로드 기능 제공
- Data Protector: AES-128을 이용한 암/복호화 기능 제공
- Infinity Value: 천 단위 그룹이 있는 무한한 숫자를 위한 값의 구조체 제공
- Smart Addressables: 유니티 어드레서블 사용의 편의성과 효율성 제공
- Lite DB: SQLite를 사용하여 데이터를 효율적으로 관리하도록 기능 제공
Quick Start
Section titled “Quick Start”Config
Section titled “Config”ConfigManager에 추가된 모든 데이터는 PlayerPrefs에 저장됩니다.
ConfigManager.AddKey("Sound", 0);ConfigManager.AddKey("BGM", 0);ConfigManager.AddKey("DataKey", "DataValue");
var sound = ConfigManager.GetConfig("Sound");ConfigManager.SetConfig("Sound", 100);에디터 설정:
PopupManager를 Hierarchy에 추가합니다. (DontDestroyOnLoad로 활성화됩니다.)PopupManager컴포넌트의popupsField에 사용할 Popup들을 모두 캐싱합니다.
public class SettingPopup : Popup{ // ...}public class CommonPopup : Popup{ // ...}public class SettingData{ public int Volume; // ...}
// Calling GetPopup will also trigger the popup's Open method.var commonPopup = PopupManager.GetPopup<CommonPopup>();
// objName : Txt_Level, TMP Supportvar lvTxt = commonPopup.Get<Text>("Level");var lvTxt = commonPopup.Get<TMP_Text>("Level");
SettingData data = new SettingData { Volume = 200 };var settingPopup = PopupManager.GetPopup<SettingPopup>(data);Time Management
Section titled “Time Management”TimeManager로 현재 시간을 받아오거나, 게임의 TimeScale를 조정합니다.
DateTime now = TimeManager.Now;TimeManager.TimeScale = 2;UIBinding using UniTaskPubSub
Section titled “UIBinding using UniTaskPubSub”hadashiA/UniTaskPubSub을 사용한 기능입니다.
기능에 대한 설명은 링크를 참조해주세요.
이 설정을 통해 이벤트 관리가 간소화됩니다. UI 호출 및 상태 변경 처리에 용이합니다.
// RegisterUIBindingManager.Subscribe<SettingData>(data =>{ SetVolume(data.Volume);});
// CallUIBindingManager.Publish(new SettingData { Volume = 5 });Singleton
Section titled “Singleton”- MonoSingleton: MonoBehavior를 상속 받는 Singleton
- PersistentMonoSingleton: MonoSingleton과 같은 기능이지만
DontDestroyOnLoad로 로드합니다. - Singleton: MonoBehavior 상속받지 않는 객체를 Singleton으로 사용합니다.
Logging
Section titled “Logging”패키지에는 기본 Log 클래스가 포함되어 있습니다. (GameLog)
사용자 지정이 필요한 경우 IGameLog 에서 상속하여 사용자 지정 로거를 구현할 수 있습니다.
패키지의 GameLog.cs 를 참조하세요.
GameLog.Debug("Debug");GameLog.Info("Info");GameLog.Warning("Warning");GameLog.Error("Error");throw GameLog.Fatal("Fatal");UnityWebRequest Wrapper
Section titled “UnityWebRequest Wrapper”이 class는 UnityWebRequest를 간편하게 사용하기 위해 제작되었습니다.
var result = new HttpLink.Builder() .SetUrl("https://jsonplaceholder.typicode.com/posts/1") .SetMethod("GET") .Build();await result.SendAsync();if (result.Success){ var resultBytes = result.ReceiveData; var resultStr = result.ReceiveDataString;}