using UnityEngine; public class Managers : MonoBehaviour { static Managers s_instance; // static으로 유일성 보장 static Managers Instance { get { Init(); return s_instance; } } // 유일한 매니저를 가져온다. InputManager _input = new InputManager(); ResourceManager _resource = new ResourceManager(); SceneManagerEx _scene = new SceneManagerEx(); SoundManager _sound = new SoundManager(); UIManager _ui = new UIManager(); public static InputManager Input { get { return Instance._input; } } public static ResourceManager Resource { get { return Instance._resource; } } public static SceneManagerEx Scene { get { return Instance._scene; } } public static SoundManager Sound { get { return Instance._sound; } } public static UIManager UI { get { return Instance._ui; } } // Start is called once before the first execution of Update after the MonoBehaviour is created void Start() { Init(); } // Update is called once per frame void Update() { _input.OnUpdate(); } static void Init() { if (s_instance == null) { GameObject go = GameObject.Find("@Managers"); if (go == null) { go = new GameObject("@Managers"); go.AddComponent(); } DontDestroyOnLoad(go); s_instance = go.GetComponent(); s_instance._sound.Init(); } } public static void Clear() { Sound.Clear(); Input.Clear(); Scene.Clear(); UI.Clear(); } }