static void SetUIElementPosition(GuiBase obj, float height, float width, Vector2 anchorPos) { if (obj.GetComponent <RectTransform>() != null) { SetUIElementPosition(obj.GetComponent <RectTransform>(), height, width, anchorPos); } }
GuiBase Display_SetParent(string guiTypeName, Transform parentTrans, JSONNode pParams) { GuiBase guiBase = null; if (_showGuiEntityList.TryGetValue(guiTypeName, out guiBase)) { if (parentTrans == guiBase.transform.parent) { return(guiBase); } 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); } } return(guiBase); }
public T Show_Name <T>(string guiTypeName, ELayerType pLayer, bool pShow, JSONNode pParams) where T : GuiBase { 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 가 같다면 guiBase = Display_SetParent(guiTypeName, parentTrans, pParams); if (guiBase != null) { return(guiBase as T); } for (int i = 0; i < _guiEntityPools.Count; ++i) { guiBase = _guiEntityPools[i]; if (guiTypeName == guiBase.GetType().ToString()) { _showGuiEntityList.Add(guiTypeName, guiBase); guiBase.SetParameter(pParams); Display_SetParent(guiTypeName, parentTrans, pParams); 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)) { // cache로 옮긴다. guiBase.OnFinish(); guiBase.transform.SetParent(_TransCache); guiBase.transform.localPosition = Vector3.zero; guiBase.transform.localRotation = Quaternion.identity; guiBase.transform.localScale = Vector3.one; UIAnchor anchortmp = guiBase.GetComponent <UIAnchor>(); if (anchortmp) { anchortmp.uiCamera = _TransCache.GetComponent <Camera>(); } //guiBase.StopAllCoroutines(); //guiBase.gameObject.SetActive(false); if (_guiEntityPools.Contains(guiBase) == false) { _guiEntityPools.Add(guiBase); } } //if (pLayer == ELayerType.Front) //{ // // 팝업닫으면 백 이밴트는 다시 킨다. // _BackUICamera.enabled = true; //} return(guiBase as T); } }