UT Generic Singleton
Generic Singleton provides a robust singleton implementation that guarantees safe access to singleton instances even when called from Awake or OnEnable events. Designed for development convenience and reliability, it uses FindObjectOfType to prevent null reference errors during early initialization phases, with migration to dependency injection recommended for production optimization.
com.eu4ng.utility.generic-singleton 
Install via UPM
Add to Unity Package Manager using this URL
https://www.pkglnk.dev/generic-singleton.git README Markdown
Copy this to your project's README.md
## Installation
Add **UT Generic Singleton** to your Unity project via Package Manager:
1. Open **Window > Package Manager**
2. Click **+** > **Add package from git URL**
3. Enter:
```
https://www.pkglnk.dev/generic-singleton.git
```
[](https://www.pkglnk.dev/pkg/generic-singleton)README
Generic Singleton
๊ฐ์
๋ค๋ฅธ ํด๋์ค์ Awake ํน์ OnEnable ์ด๋ฒคํธ์์ ์ฑ๊ธํค ๊ฐ์ฒด์ ์ ๊ทผํ๋ ๊ฒฝ์ฐ์๋ null ์ค๋ฅ๋ฅผ ๋ฐ์์ํค์ง ์๋ ์ ๋ค๋ฆญ ์ฑ๊ธํค ํด๋์ค์ด๋ค. ์ต์ ํ๋ณด๋ค๋ ๊ฐ๋ฐ์ ํธ์์ฑ๊ณผ ์ฑ๊ธํค ๊ฐ์ฒด ์ ๊ทผ์ ๋ํ ๋ณด์ฅ์ ๋ชฉํ๋ก ์ค๊ณํ์๋ค.
์ผ๋ฐ์ ์ผ๋ก๋ ์ฑ๊ธํค ๊ฐ์ฒด์ Awake ์ด๋ฒคํธ์์ ์๊ธฐ ์์ ์ ์ง์ ํ ๋นํ๋ฏ๋ก ๋ฌธ์ ๊ฐ ์์ง๋ง, ๋ค๋ฅธ ํด๋์ค์ Awake ํน์ OnEnable ์ด๋ฒคํธ์์ ์ค๊ธํค ๊ฐ์ฒด์ ์ ๊ทผํ๋ ๊ฒฝ์ฐ์๋ FindObjectOfType ๋ฉ์๋๋ฅผ ์ฌ์ฉํ๋ฏ๋ก ์ต์ ํ๋ฅผ ์ํด์๋ ์ถํ์ ์์กด์ฑ ์ฃผ์
๋ฐฉ์์ผ๋ก ์ ํ์ ๊ถ์ฅํ๋ค.
ํด๋์ค ๋ค์ด์ด๊ทธ๋จ

์์๋

No comments yet. Be the first!