it leader
article thumbnail
[Unity3D] 싱글턴 패턴에서 인스턴스가 중복하여 생성되는 것을 방지하는 방법
코딩공부/Unity3D 2016. 5. 13. 16:45

싱글턴 패턴으로 생성한 객체를 다시 인스턴스화 하였을 때에 오브젝트가 재생산 되는 것을 방지하기 위한 코드 1234567891011121314 void Awake(){ if( instance != null) { Destroy(this.gameObject); // 해당 스크립트를 삭제 return; } instance = this; DontDestroyOnLoad(this); Application.targetFrameRate = 60; //최대 프레임수를 60으로 지정 }Colored by Color Scriptercs 하단에 Application.targetFrameRate = 60; 이부분은 크게 주제와 관계는 없어 보인다. 싱글턴 패턴 사용법이 궁금하신 분들은 아래 링크 참조 2016/05/13 - ..

article thumbnail
[Unity3D] 싱글턴 패턴 사용법
코딩공부/Unity3D 2016. 5. 13. 16:43

싱글턴 패털 사용법이 여러종류가 있습니다. 간단하게 싱글턴으로 만들 클래스 도입부에 싱글턴 선언을 하여 사용하는 방법 12345678910111213141516171819202122232425262728293031323334353637383940414243444546using UnityEngine;using System.Collections; public class SingletonTest : MonoBehaviour { private static SingletonTest instance; private static GameObject container; public static SingletonTest GetInstance(){ if(!instance){ container = new GameObject..