singleton [유니티 스크립트 소스] 싱글톤(Singleton) 2 2022. 6. 16. using UnityEngine; using System; using UnityEngine.SceneManagement; /// /// Singleton attribute work with singleton class. /// public class SingletonAttribute : Attribute { //Tell if this singleton has to create himself if he is called and not present in the scene. public bool createIfNotPresent; public SingletonAttribute(bool b) { createIfNotPresent = b; } } /// /// Be aware this will not preve.. [유니티 스크립트 소스] 싱글톤(Singleton) 2020. 3. 7. 1. 싱글톤 정의 using UnityEngine; public class GameController : MonoBehaviour { public static GameController instance = null; public static GameController Instance { get { return instance; } } void Awake() { instance = this; } } 2. 싱글톤 선언 using UnityEngine; public class PlayerController : MonoBehaviour { private GameController m_Game; void Start() { m_Game = GameController.instance; } } 이전 1 다음