public Tuple <Transform, Transform> Back() { if (_uiStack.Count > 1) { UIBase hideUI = _uiStack.Pop(); Transform shouUI = null; if (hideUI.GetUiLayer() == UILayer.BASIC_UI) { hideUI.UiState = UIState.HIDE; _uiStack.Peek().UiState = UIState.SHOW; shouUI = _uiStack.Peek().transform; } else { hideUI.UiState = UIState.HIDE; } return(new Tuple <Transform, Transform>(shouUI, hideUI.transform)); } else { Debug.LogError("uistack has one or no element"); return(null); } }
public Tuple <Transform, Transform> Show(UiId id) { GameObject ui = GetPrefabObject(id); if (ui == null) { Debug.LogError("can not find prefab " + id); return(null); } UIBase uiScript = GetUiScript(ui, id); if (uiScript == null) { return(null); } InitUi(uiScript); Transform hideUI = null; if (uiScript.GetUiLayer() == UILayer.BASIC_UI) { uiScript.UiState = UIState.SHOW; hideUI = Hide(); } else { uiScript.UiState = UIState.SHOW; } _uiStack.Push(uiScript); return(new Tuple <Transform, Transform>(ui.transform, hideUI));; }
private void InitUi(UIBase uiScript) { if (uiScript.uiState == UIState.NORMAL) { Transform ui = uiScript.transform; ui.SetParent(GetLayerObject?.Invoke(uiScript.GetUiLayer())); ui.localPosition = Vector3.zero; ui.localScale = Vector3.one; ui.RectTransform().offsetMax = Vector2.zero; ui.RectTransform().offsetMin = Vector2.zero; InitCallBack?.Invoke(ui); } }
private void UpdateUI(UIBase view) { if (view.UiState == UIState.NORMAL) { Transform transform = view.transform; transform.SetParent(GetLayerObject?.Invoke(view.GetUiLayer())); transform.localPosition = Vector3.zero; transform.localScale = Vector3.one; transform.RectTransform().offsetMax = Vector2.zero; transform.RectTransform().offsetMin = Vector2.zero; InitCallBack?.Invoke(transform); } }
public Tuple <Transform, Transform> Show(UiId id) { //根据id实例化对应的view. /* * 获取对应UIBase, initUI * 如果当前UI是baseUI,则隐藏当前的View * push当前UI.' * 返回tuple, ui.transform, hideUI */ var prefab = GetPrefabObject(id); if (prefab == null) { Debug.LogError("can not find prefab " + id); return(null); } UIBase view = GetUIScript(prefab, id); if (view == null) { Debug.LogError("can not find UIBase " + id); return(null); } UpdateUI(view); Transform hideUI = null; if (view.GetUiLayer() == UILayer.BASIC_UI) { hideUI = Hide(); if (hideUI != null) { Debug.Log("hideUI:" + hideUI.gameObject.name); } } view.UiState = UIState.SHOW; _uiStack.Push(view); return(new Tuple <Transform, Transform>(view.transform, hideUI)); }
public Tuple <Transform, Transform> Back() { if (_uiStack.Count > 1) { Transform showView = null; UIBase hideView = _uiStack.Pop(); if (hideView.GetUiLayer() == UILayer.BASIC_UI) { _uiStack.Peek().UiState = UIState.SHOW; showView = _uiStack.Peek().transform; hideView.UiState = UIState.HIDE; } else { hideView.UiState = UIState.HIDE; } return(new Tuple <Transform, Transform>(showView, hideView.transform)); } Debug.LogError("uistack has one or no element"); return(null); }