using System.Resources; using UnityEngine; public class Managers : MonoBehaviour { static Managers s_instance; static Managers Instance { get { init(); return s_instance; } } InputManager _input = new InputManager(); ResourceManager _resource = new ResourceManager(); UIManager _ui = new UIManager(); public static InputManager Input { get { return Instance._input; } } public static ResourceManager Resource { get { return Instance._resource; } } public static UIManager UI { get { return Instance._ui; } } static void init() { if (s_instance == null) { GameObject obj = GameObject.Find("@Managers"); if (obj == null) { obj = new GameObject { name = "@Managers" }; obj.AddComponent(); } DontDestroyOnLoad(obj); s_instance = obj.GetComponent(); } } // 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(); } }