/// <summary> /// Checks if the display panel request is valid and raises retrieve signal. /// </summary> private void RetrievePanel(IPanelVo panelVo) { if (panelVo.LayerIndex >= View.Layers.Length) { Debug.LogError("There is no layer " + panelVo.LayerIndex); return; } CoreScreenSignals.RetrievePanel.Dispatch(panelVo); }
/// <summary> /// Receives the display panel request /// </summary> private void OnDisplayPanel(IPanelVo panelVo) { if (panelVo.Key == null) { Debug.LogError("Panel is null"); return; } Debug.Log("Displaying Panel " + panelVo.Key); RetrievePanel(panelVo); }
/// <summary> /// Remove the current page. Check the previous page and load it. /// </summary> private void OnBack() { if (ScreenModel.History.Count < 2) { return; } ScreenModel.History.RemoveAt(ScreenModel.History.Count - 1); IPanelVo prePanelVo = ScreenModel.History[ScreenModel.History.Count - 1]; ScreenModel.History.RemoveAt(ScreenModel.History.Count - 1); //Creating signal argument CoreScreenSignals.DisplayPanel.Dispatch(prePanelVo); }
/// <summary> /// Create the panel and set the transform of gameobject /// </summary> /// <param name="vo"> PanelVo which is stored on View objects, if it is a screen </param> /// <param name="template"> Prefab to create </param> private void CreatePanel(IPanelVo panelVo, GameObject template) { Debug.Log("Creating Panel " + panelVo.Key); if (panelVo.RemoveSamePanels) { RemoveSamePanels(panelVo.Key, panelVo.LayerIndex); } if (panelVo.RemoveLayer) { RemoveLayer(panelVo.LayerIndex); } if (panelVo.RemoveAll) { RemoveAllPanels(); } //This can be a pool! GameObject newPanel = Instantiate(template, View.Layers[panelVo.LayerIndex]); IPanel panel = newPanel.GetComponent <IPanel>(); RichView view = panel as RichView; if (view == null) { Debug.LogError("This is not a view!", newPanel); return; } Debug.Log("Setting Panel Vo"); panel.vo = panelVo; view.Initialize(); newPanel.transform.SetParent(View.Layers[panelVo.LayerIndex], false); newPanel.transform.localScale = Vector3.one; _panels.Add(newPanel); if (!panelVo.IgnoreHistory) { ScreenModel.History.Add(panel.vo); } ScreenModel.CurrentPanels.Add(panel.vo); //Debug.Log("---------------------" + vo.Type); }