An open API service indexing awesome lists of open source software.

https://github.com/solutena/getable


https://github.com/solutena/getable

getable singleton unity

Last synced: about 2 months ago
JSON representation

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`해오기 전에 게임오브젝트가 한번은 켜져있어야 합니다.