Unity客户端架构-io
发表于2018-09-05
继续Unity客户端架构系列的介绍,上一篇中给大家介绍了UIContainer的使用,这一篇我们就来看看io的使用。
using UnityEngine; using System.Collections; //管理调用Manager public class io : MonoBehaviour { private static GameObject _manager; private static GameManager _gameManager; private static PanelManager _panelManager; private static DialogManager _dialogManager; private static MusicManager _musicManager; private static UIContainer _container; public static GameObject manager { get { if (io._manager == null) { io._manager = GameObject.FindWithTag("GameManager"); } return io._manager; } } public static GameManager gameManager { get { if (io._gameManager == null) { io._gameManager = io.manager.GetComponent<GameManager>(); } return io._gameManager; } } public static PanelManager panelManager { get { if (io._panelManager == null) { io._panelManager = io.manager.GetComponent<PanelManager>(); } return io._panelManager; } } public static DialogManager dialogManager { get { if (io._dialogManager == null) { io._dialogManager = io.manager.GetComponent<DialogManager>(); } return io._dialogManager; } } public static GameObject Gui { get { return GameObject.FindWithTag("GUI"); } } public static UIContainer container { get { if (io._container == null) { io._container = io.Gui.GetComponent<UIContainer>(); } return io._container; } } }
Unity客户端架构系列教程