Unity3D
유니티 싱글톤.
에브리피플
2015. 5. 13. 16:08
- 모노디벨롭을 상속받는 클래스의경우
public class GeneralWindow : MonoBehaviour {
#region 인스턴스
private static GeneralWindow _instance;
public static GeneralWindow In {
get {
return _instance;
}
}
#endregion
#region 유니티메서드
void Awake() {
_instance = this;
}
void Start() {
}
#endregion
- 상속받지않는 일반 클래스의경우
public class GeneralDataFile{
#region 인스턴스
private static GeneralDataFile _instance = new
GeneralDataFile();
public static GeneralDataFile In {
get {
return _instance;
}
}
#endregion
그냥 에디터에서
Static 체크하면 instance로 접근가능