public void OpenUI(string uiName, string groupName, string luaName) { // Awake的模拟 // 要打开一个UI时先判断UI池中是否存在这个UI,如果有直接打开,如果没有先创建 GameObject go = null; string uiPath = PathUtil.GetUIPath(uiName); Object uiObj = Manager.Pool.Spawn("UI", uiPath); UILogic uiLogic = null; if (uiObj != null) { go = uiObj as GameObject; uiLogic = go.GetComponent <UILogic>(); Transform parent = GetUIGroup(groupName); go.transform.SetParent(parent, false); uiLogic.OnOpen(); // Start return; } Manager.Resource.LoadUI(uiName, (UnityEngine.Object obj) => { go = Instantiate(obj) as GameObject; Transform parent = GetUIGroup(groupName); go.transform.SetParent(parent, false); // m_UI.Add(uiName,go); uiLogic = go.AddComponent <UILogic>(); uiLogic.UIName = uiPath; uiLogic.Init(luaName); uiLogic.OnOpen(); // Start }); }