유니티(unity)
[1분 해결] 유니티(unity) 싱글톤 구현
개발자 고포고
2021. 10. 26. 12:28
반응형
[1분 해결] 유니티(unity) 싱글톤 구현
구현
public class NFCHelper : MonoBehaviour
{
private static NFCHelper instance = null;
void Awake()
{
if (null == instance)
{
instance = this;
DontDestroyOnLoad(this.gameObject);
}
else
{
Destroy(this.gameObject);
}
}
public static NFCHelper Instance
{
get
{
if (null == instance)
{
return null;
}
return instance;
}
}
public void Test(){
}
}
사용
NfcHelper.Instance.Test()
태그
반응형