https://github.com/solutena/getable
https://github.com/solutena/getable
getable singleton unity
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/solutena/getable
- Owner: solutena
- Created: 2023-09-18T10:20:21.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2024-05-13T00:55:04.000Z (about 2 years ago)
- Last Synced: 2025-03-01T07:42:23.260Z (over 1 year ago)
- Topics: getable, singleton, unity
- Language: C#
- Homepage:
- Size: 10.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Getable
싱글턴 대신 사용할 수 있는
고유하게 존재하는 타입을 가져오기 위한 디자인 패턴입니다.
UI에서 유용하게 사용할 수 있습니다.
# 예제
```
public class PlayerUI : Getable
{
//스크립트
}
```
Getable을 상속하면
```
public class OtherUI : MonoBehaviour
{
void Start
{
PlayerUI playerUI = Getable.Get();
}
}
```
다음과 같이 다른 스크립트에서 Getable.Get<타입>() 함수로 가져올 수 있습니다.
`Awake`에서 추가하고, `OnDestroy`에서 제거되므로
`Get`해오기 전에 게임오브젝트가 한번은 켜져있어야 합니다.