public T Show <T>(ELayerType pLayer, bool pShow, JSONNode pParams) where T : GuiBase { string guiTypeName = typeof(T).ToString(); if (pShow) { GuiBase guiBase; Transform parentTrans = null; switch (pLayer) { case ELayerType.Back: { parentTrans = _TransBack; // GameObject.Find("Gui/Back/Camera").transform; _BackUICamera.enabled = true; } break; case ELayerType.Front: { parentTrans = _TransFront; // GameObject.Find("Gui/Front/Camera").transform; // 팝업 시 백 이밴트는 끈다. _BackUICamera.enabled = false; } break; case ELayerType.Cache: { parentTrans = _TransCache; // GameObject.Find("Cache").transform; } break; } // 이미 보이는 중이고 리턴. parentTrans 가 같다면 if (_showGuiEntityList.TryGetValue(guiTypeName, out guiBase)) { if (parentTrans == guiBase.transform.parent) { return(guiBase as T); } else { guiBase.transform.parent = parentTrans; guiBase.transform.localPosition = Vector3.zero; guiBase.transform.localRotation = Quaternion.identity; guiBase.transform.localScale = Vector3.one; guiBase.SetParameter(pParams); UIAnchor anchortmp = guiBase.GetComponent <UIAnchor>(); if (anchortmp) { anchortmp.uiCamera = parentTrans.GetComponent <Camera>(); } return(guiBase as T); } } if (_hideGuiEntityList.TryGetValue(guiTypeName, out guiBase)) { guiBase.StopAllCoroutines(); guiBase.gameObject.SetActive(false); _hideGuiEntityList.Remove(guiTypeName); _showGuiEntityList.Add(guiTypeName, guiBase); guiBase.SetParameter(pParams); guiBase.gameObject.SetActive(true); return(guiBase as T); } for (int i = 0; i < _guiEntityPools.Count; ++i) { guiBase = _guiEntityPools[i]; if (guiTypeName == guiBase.GetType().ToString()) { _guiEntityPools.RemoveAt(i); _showGuiEntityList.Add(guiTypeName, guiBase); guiBase.SetParameter(pParams); guiBase.gameObject.SetActive(true); return(guiBase as T); } } GameObject guiGO = (GameObject)GameObject.Instantiate(Resources.Load(string.Format("Gui/{0}", guiTypeName))); guiGO.name = guiTypeName; guiGO.transform.parent = parentTrans; guiGO.transform.localPosition = Vector3.zero; guiGO.transform.localRotation = Quaternion.identity; guiGO.transform.localScale = Vector3.one; guiBase = (GuiBase)guiGO.GetComponent(guiTypeName); _showGuiEntityList.Add(guiTypeName, guiBase); guiBase.SetParameter(pParams); // UIAnchor 가 있다면 적용. UIAnchor anchortmp1 = guiBase.GetComponent <UIAnchor>(); if (anchortmp1) { anchortmp1.uiCamera = parentTrans.GetComponent <Camera>(); } return(guiBase as T); } else { GuiBase guiBase = null; if (_showGuiEntityList.TryGetValue(guiTypeName, out guiBase)) { _showGuiEntityList.Remove(guiTypeName); _hideGuiEntityList.Add(guiTypeName, guiBase); guiBase.OnFinish(); guiBase.StopAllCoroutines(); guiBase.gameObject.SetActive(false); } if (pLayer == ELayerType.Front) { // 팝업닫으면 백 이밴트는 다시 킨다. _BackUICamera.enabled = true; } return(guiBase as T); } }