public void ClosePanel(UIPanelBase uIPanelBase) { if (uIPanelBase.IsActive) { CloseByEffect(uIPanelBase); } }
/// <summary> /// 根据面板与对象相对路径获取目标对象 /// </summary> /// <param name="panelId">对象依赖面板</param> /// <param name="relativePath">相对面板路径</param> /// <returns></returns> public static GameObject FindGameObjByPanel(PanelID panelId, string relativePath) { UIPanelBase panelbase = DataManager.Manager <UIPanelManager>().GetPanel(panelId); if (null == panelbase) { if (UIDefine.IsUIDebugLogEnable) { Engine.Utility.Log.Error("UIManager->FindGameObjByPanel faield,unknow panelId:{0}" , panelId); } return(null); } Transform ts = panelbase.CacheTransform.Find(relativePath); if (null == ts) { if (UIDefine.IsUIDebugLogEnable) { Engine.Utility.Log.Error("UIManager->FindGameObjByPanel faield,unknow path:{0}\npanelid:{1}" , relativePath, panelId); } return(null); } return(ts.gameObject); }
protected void CreateTabs(UIPanelBase panelBase) { if (panelBase.PanelInfo != null && panelBase.PanelInfo.PanelTaData.Enable) { AddTab(panelBase); } }
/// <summary> /// 返回上一面板 /// </summary> public void GoBack() { //关闭最顶层面板 if (uiStack.Count > 1) { UIPanelBase uIPanelBase = uiStack.Pop(); //林奕州2020/3/3修改:限制返回到起始页 if (uiStack.Peek().gameObject.name == firstPanel.name + "(Clone)") { uiStack.Push(uIPanelBase); Debug.Log("已经返回到底部"); return; } uIPanelBase.OnExit(); CloseByEffect(uIPanelBase); //恢复显示下一层面板 if (uiStack.Count > 0) { UIPanelBase uIPanelBase1 = uiStack.Peek(); uIPanelBase1.OnResume(); uIPanelBase1.transform.SetAsLastSibling(); OpenByEffect(uIPanelBase1); //var cg = GetCanvasGroup(uIPanelBase1); //cg.interactable = true; } } }
/// <summary> /// 面板资源是否准备好 /// </summary> /// <param name="localInfo"></param> /// <returns></returns> private bool IsPanelAssetReady(LocalPanelInfo localInfo) { UIPanelBase tempPanel = null; bool ready = true; if (localInfo.NeedBg && ready) { tempPanel = GetPanel(PanelID.CommonBgPanel); if (null == tempPanel) { ready = false; } } if (localInfo.NeedTopBar && ready) { tempPanel = GetPanel(PanelID.TopBarPanel); if (null == tempPanel) { ready = false; } } tempPanel = GetPanel(localInfo.PID); if (null == tempPanel) { ready = false; } return(ready); }
/// <summary> /// 打开子面板 /// </summary> public void OpenChildPanel(UIPanel panelName, object msg = null) { UIPanel myName = Name; UIViewStateRestore info = new UIViewStateRestore(); info.PageIndex = State.GetPageIndex(); info.CategoryIndex = State.GetPageCategoryIndex(info.PageIndex); info.SortIndex = State.GetPage().SortIndex; info.CompareMode = State.IsCompareMode(); info.CompareIndex = State.GetCompareIndex(); info.LayoutMode = State.GetPage().ListLayoutMode; info.SelectionIndex = State.GetPage().ListSelection; info.SelectionOffset = State.GetPage().ListSelectionOffset; UIManager.Instance.ClosePanel(this); UIManager.Instance.OpenPanel(panelName, msg); UIPanelBase panel = UIManager.Instance.GetPanel(panelName); if (panel != null) { if (m_ViewStateRestore.ContainsKey(myName)) { m_ViewStateRestore.Remove(myName); } m_ViewStateRestore.Add(myName, info); panel.OnClosed += () => { UIManager.Instance.OpenPanel(myName); }; } }
public void OnSelectionChange() { bool somethingChanged = false; if (panel != null) { if (panel.gameObject != Selection.activeGameObject) { somethingChanged = true; } } else { somethingChanged = true; } if (somethingChanged) { if (Selection.activeGameObject != null) { panel = (UIPanelBase)Selection.activeGameObject.GetComponent(typeof(UIPanelBase)); selGO = Selection.activeGameObject; curTrans = 0; curTransElement = 0; } else { selGO = null; panel = null; } } Repaint(); }
/// <summary> /// Dismisses the currently showing panel, if any, /// in the direction specified. /// </summary> /// <param name="dir">The direction in which the panel is to be dismissed.</param> public void Dismiss(MENU_DIRECTION dir) { StartCoroutine("Start"); if (dir == MENU_DIRECTION.Auto) { dir = MENU_DIRECTION.Backwards; } SHOW_MODE mode = ((dir == MENU_DIRECTION.Forwards) ? (SHOW_MODE.DismissForward) : (SHOW_MODE.DismissBack)); if (curPanel != null) { StartAndTrack(curPanel, mode); } curPanel = null; // Only push on a null ref if there // isn't already one on the stack: if (breadcrumbs.Count > 0) { if (breadcrumbs[breadcrumbs.Count - 1] != null) { breadcrumbs.Add(null); } } }
public void AddChild(GameObject go) { IUIObject iUIObject = (IUIObject)go.GetComponent("IUIObject"); if (iUIObject != null) { if (iUIObject.Container != this) { iUIObject.Container = this; } if (!this.uiObjs.ContainsKey(iUIObject.GetHashCode())) { this.uiObjs.Add(iUIObject.GetHashCode(), iUIObject); } } else { UIPanelBase uIPanelBase = (UIPanelBase)go.GetComponent(typeof(UIPanelBase)); if (uIPanelBase != null) { if (uIPanelBase.Container != this) { uIPanelBase.Container = this; } this.childPanels.Add(new EZLinkedListNode <UIPanelBase>(uIPanelBase)); } } if (!base.gameObject.activeInHierarchy) { go.SetActive(false); } }
public override void OnInspectorGUI() { base.OnInspectorGUI(); isDirty = false; panel = (UIPanelBase)target; GUILayout.BeginVertical(); //----------------------------------------- // Draw our transition stuff: //----------------------------------------- if (panel.Transitions != null) if (panel.Transitions.list != null) if (panel.Transitions.list.Length > 0) DoTransitionStuff(); GUILayout.Space(10f); GUILayout.EndVertical(); // Set dirty if anything changed: if (isDirty) EditorUtility.SetDirty(panel); }
public void AddChild(GameObject go) { IUIObject obj = (IUIObject)go.GetComponent("IUIObject"); if (obj != null) { if (obj.Container != (IUIContainer)this) { obj.Container = this; } uiObjs.Add(new EZLinkedListNode <IUIObject>(obj)); } else { UIPanelBase panel = (UIPanelBase)go.GetComponent(typeof(UIPanelBase)); if (panel != null) { if (panel.Container != (IUIContainer)this) { panel.Container = this; } childPanels.Add(new EZLinkedListNode <UIPanelBase>(panel)); } } // Disable the new child if we are also disabled: if (!gameObject.active) { go.SetActiveRecursively(false); } AddSubject(go); }
public void ScanChildren() { this.uiObjs.Clear(); Component[] componentsInChildren = base.transform.GetComponentsInChildren(typeof(IUIObject), true); for (int i = 0; i < componentsInChildren.Length; i++) { if (!(componentsInChildren[i] == this)) { if (base.gameObject.layer == NrTSingleton <UIManager> .Instance.rayMask) { UIPanelManager.SetLayerRecursively(componentsInChildren[i].gameObject, base.gameObject.layer); } IUIObject iUIObject = (IUIObject)componentsInChildren[i]; if (!this.uiObjs.ContainsKey(componentsInChildren[i].GetHashCode())) { this.uiObjs.Add(componentsInChildren[i].GetHashCode(), (IUIObject)componentsInChildren[i]); } iUIObject.RequestContainership(this); } } componentsInChildren = base.transform.GetComponentsInChildren(typeof(UIPanelBase), true); for (int j = 0; j < componentsInChildren.Length; j++) { if (!(componentsInChildren[j] == this)) { if (base.gameObject.layer == NrTSingleton <UIManager> .Instance.rayMask) { UIPanelManager.SetLayerRecursively(componentsInChildren[j].gameObject, base.gameObject.layer); } UIPanelBase uIPanelBase = (UIPanelBase)componentsInChildren[j]; this.childPanels.Add(new EZLinkedListNode <UIPanelBase>(uIPanelBase)); uIPanelBase.RequestContainership(this); } } }
/// <summary> /// /// </summary> /// <param name="panel"></param> /// <param name="nTabIndex">索引</param> /// <param name="nTabType">第几类页签</param> public void OnCilckTogglePanel(ref UIPanelBase panel, int nTabType, int nTabIndex) { if (null == panel) { return; } UIPanelManager.PanelTabData.PanelTabUnit unit = null; if (null == panel.PanelInfo || !panel.PanelInfo.PanelTaData.TryGetTabUnit(nTabIndex, out unit)) { Engine.Utility.Log.Error("Panel LocalInfo Error id:{0}!", panel.PanelId); return; } int openLv = 0; if (!DataManager.Manager <GuideManager>().IsTabFuncOpen(unit.FuncID, out openLv)) { TipsManager.Instance.ShowLocalFormatTips(LocalTextType.Trailer_Commond_xitongyeqiankaiqi, unit.EnumName, openLv); return; } bool reset = panel.OnTogglePanel(nTabType, nTabIndex); if (reset) { panel.dicActiveTabGrid[nTabType] = nTabIndex; Dictionary <int, UITabGrid> dicTabs = null; if (panel.dicUITabGrid.TryGetValue(nTabType, out dicTabs)) { foreach (var item in dicTabs) { item.Value.SetHightLight(item.Value.TabID == nTabIndex); } } } }
private void openWindow(UIPanelBase panel, bool active, params object[] paramsList) { Debuger.Log("begin open window and the pannel is " + panel.name); if (panel == null || panel.gameObject == null) { Debuger.LogError("the panel is null"); return; } if (g_LoadedWindow == null) { Debuger.LogError("the loaded window is null"); return; } // change window status if (active) { //DontUseThisShowPanel(panel, paramsList); } else { Debuger.Log("show window false and the panel name is " + panel.name); if (panel.gameObject.activeInHierarchy) { panel.OnClose(); panel.gameObject.SetActive(false); ManageActiveWindow(false, panel); } } }
public void addLoadedWindow(string name, UIPanelBase panel, bool isActive) { if (g_LoadedWindow == null) { return; } long inactiveTime = 0; if (isActive) { inactiveTime = 0; } else { inactiveTime = DateTime.Now.Ticks; } if (g_LoadedWindow.ContainsKey(name)) { g_LoadedWindow[name].isActive = isActive; g_LoadedWindow[name].inActiveTime = inactiveTime; g_LoadedWindow[name].activeTime = DateTime.Now.Ticks; g_LoadedWindow[name].panel = panel; return; } g_LoadedWindow.Add(name, new WindowActiveTimeData(name, isActive, inactiveTime, DateTime.Now.Ticks, panel)); }
/// <summary> /// Brings in the specified panel in a manner /// that portrays the menu moving in the /// specified direction. If "Auto" is specified /// for the direction, forward/backward is /// determined by comparing the index of the /// current panel to the one being brought up. /// </summary> /// <param name="panel">Reference to the panel to bring up.</param> /// <param name="dir">Direction the menu should appear to be moving. /// If "Auto" is specified, the direction is determined by comparing /// the index of the current panel to the one being brought up.</param> public void BringIn(UIPanelBase panel, MENU_DIRECTION dir) { StartCoroutine("Start"); SHOW_MODE dismissMode; SHOW_MODE bringInMode; if (curPanel == panel) { return; // Nothing to do! } if (dir == MENU_DIRECTION.Auto) { // See if we can determine the direction: if (curPanel != null) { // Forward if (curPanel.index <= panel.index) { dir = MENU_DIRECTION.Forwards; } else // Backward { dir = MENU_DIRECTION.Backwards; } } else // Assume forward: { dir = MENU_DIRECTION.Forwards; } } dismissMode = ((dir == MENU_DIRECTION.Forwards) ? (SHOW_MODE.DismissForward) : (SHOW_MODE.DismissBack)); bringInMode = ((dir == MENU_DIRECTION.Forwards) ? (SHOW_MODE.BringInForward) : (SHOW_MODE.BringInBack)); // Dismiss the current panel: if (curPanel != null) { StartAndTrack(curPanel, dismissMode); } // Bring in the next panel: curPanel = panel; breadcrumbs.Add(curPanel); #if UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5 || UNITY_4_6 || UNITY_4_7 || UNITY_4_8 || UNITY_4_9 if (deactivateAllButInitialAtStart && !curPanel.gameObject.activeInHierarchy) { curPanel.Start(); curPanel.gameObject.SetActive(true); } #else if (deactivateAllButInitialAtStart && !curPanel.gameObject.active) { curPanel.Start(); curPanel.gameObject.SetActiveRecursively(true); } #endif StartAndTrack(curPanel, bringInMode); }
public static int CompareZOrder(UIPanelBase a, UIPanelBase b) { if (a == null || b == null) { return(0); } return((int)(b.transform.position.z - a.transform.position.z)); }
public WindowActiveTimeData(string panelName, bool isActive, long inActiveTime, long activeTime, UIPanelBase panel) { this.panelName = panelName; this.isActive = isActive; this.inActiveTime = inActiveTime; this.activeTime = activeTime; this.panel = panel; }
/// <summary> /// 显示面板 /// </summary> /// <param name="panelShowData"></param> private UIPanelBase ShowPanel(PanelShowData panelShowData) { UIPanelBase pBase = GetPanel(panelShowData.PID); if (null == pBase) { Engine.Utility.Log.Error("UIPanelManager->ShowPanel pBase null,pid:{0}", panelShowData.PID); return(pBase); } if (IsShowPanel(panelShowData.PID)) { pBase.PrePanelData = panelShowData.PrePanelData; pBase.ShowPanel(panelShowData.Data, jumpData: panelShowData.JumpData); Engine.Utility.Log.Warning(CLASS_NAME + "-> ShowPanel failed,panelId = {0} already show!", panelShowData.PID.ToString()); return(pBase); } //如果存在互斥面板已经显示则直接返回 LocalPanelInfo panelInfo = null; if (TryGetLocalPanelInfo(panelShowData.PID, out panelInfo)) { List <PanelID> mutexPanels = panelInfo.MutexPanels; if (null != mutexPanels) { for (int i = 0; i < mutexPanels.Count; i++) { if (IsShowPanel(mutexPanels[i])) { DealShowPanelMutex(panelShowData.PID); return(null); } } } } //if (panelShowData.PID == PanelID.MainPanel || panelShowData.PID == PanelID.MissionAndTeamPanel) //{ // UIRootHelper.Instance.SetPanelRootStatusByType(PanelRootType.Main, true); //} ReadyPanel(pBase, panelShowData.IgnoreCache); if (pBase.PanelInfo.IsStartPanel || panelShowData.ForceResetPanel) { pBase.ResetPanel(); } DoShowPanel(pBase, panelShowData.PrePanelData, panelShowData.Data, panelShowData.JumpData); if (pBase.PanelInfo.IsStartPanel || panelShowData.ForceClearCacheBack) { ClearCacheStack(); } return(pBase); }
public UIPanelBase currentPanel; //当前在显示的UI界面 public void ShowUIPanel(string panelName) { //如果要显示的页面已经加载过 if (uiPool.ContainsKey(panelName)) { if (currentPanel == null)//如果当前没有界面在显示 { currentPanel = uiPool[panelName]; currentPanel.Show(); } else if (currentPanel.name != panelName) //如果不是当前界面 { //隐藏当前界面 currentPanel.Hide(); currentPanel = uiPool[panelName]; currentPanel.Show(); } } else//如果没有加载过 { //通过C#反射利用字符串去获取当前UI界面的控制组件的类型 System.Type t = Assembly.GetExecutingAssembly().GetType(panelName); GameObject go = ResourcesManager.Instance.LoadPrefab(panelName);//获取Panel预制体 //实例化 go = Instantiate <GameObject>(go, canvas); //添加Panel的脚本 UIPanelBase panel = go.AddComponent(t) as UIPanelBase; go.name = panelName; //加入池中 uiPool.Add(panelName, panel); //如果当前有UI界面 if (currentPanel != null) { //更换当前页面 currentPanel.Hide(); currentPanel = panel; currentPanel.Show(); } else { //没有则直接显示 currentPanel = panel; currentPanel.Show(); } } }
void OnHidePanel(GameObject go) { UIPanelBase panel = transform.GetComponentInParent <UIPanelBase>(); if (panel != null) { panel.HideSelf(); } }
static void PastePanel(UIPanelBase panel) { transList[0].CopyTo(panel.Transitions, true); transList[0].MarkAllInitialized(); EditorUtility.SetDirty(panel.gameObject); Debug.Log("Transitions Pasted"); }
static void CopyPanel(UIPanelBase panel) { transList = new EZTransitionList[1]; transList[0] = new EZTransitionList(); panel.Transitions.CopyToNew(transList[0], true); transList[0].MarkAllInitialized(); Debug.Log("Transitions Copied"); }
/// <summary> /// 创建面板 /// </summary> /// <param name="pid">面板ID</param> /// <param name="panelTs">依赖的Transform</param> /// <returns></returns> private UIPanelBase CreatePanel(PanelID pid, Transform panelTs) { UIPanelBase panelBase = GetPanel(pid); if (null == panelTs) { Engine.Utility.Log.Error("UIPanelManager->CreatePanel failed ,Panel Transform null,PID:{0}", pid); return(panelBase); } LocalPanelInfo localPanelInfo = null; if (TryGetLocalPanelInfo(pid, out localPanelInfo)) { if (null == panelBase) { string panelPath = localPanelInfo.PrefabPath; string panelClassName = localPanelInfo.PanelEnumName; GameObject go = panelTs.gameObject; if (!string.IsNullOrEmpty(panelClassName)) { go.name = panelClassName; panelBase = go.GetComponent <UIPanelBase>(); if (null == panelBase) { panelBase = Util.AddComponent(go, panelClassName) as UIPanelBase; if (null != panelBase) { panelBase.PanelInfo = localPanelInfo; if (null != go && !go.activeSelf) { go.SetActive(true); } //初始化 panelBase.Init(); panelBase.InitPanelDetph(); //go.SetActive(false); } } allPanels.Add((uint)pid, panelBase); } } else { Debug.LogError("DespawnExistpanel:" + pid.ToString()); if (IsShowPanel(pid)) { Debug.LogError("DespawnExistSSS##panel:" + pid.ToString()); } UIManager.ReleaseObjs(localPanelInfo.TableData.resID, panelTs); } } return(panelBase); }
public void ShowUIFrame(UIPanelBase panelBase, params ReturnBackUIData[] returnBackUIData) { if (panelBase.PanelId == PanelID.CommonBgPanel || panelBase.PanelId == PanelID.TopBarPanel) { return; } if (panelBase.PanelInfo == null) { return; } /* * if (panelBase.PanelInfo.NeedBg) * { * UIManager.ShowPanel(PanelID.CommonBgPanel); * } * * if (panelBase.PanelInfo.NeedTopBar) * { * if (returnBackUIData != null && returnBackUIData.Length > 0) * { * m_stackReturnBackUIData.Push(returnBackUIData); * } * else * { * if (m_startPanelID == PanelID.None) * { * m_startPanelID = panelBase.PanelId; * } * * if (m_startPanelID != PanelID.None && m_currPanelID != PanelID.None && m_startPanelID != panelBase.PanelId) * { * ReturnBackUIData[] returnUI = new ReturnBackUIData[1]; * returnUI[0] = new ReturnBackUIData() * { * panelid = m_currPanelID, * }; * m_stackReturnBackUIData.Push(returnUI); * } * } * * // Debug.LogError(uidata.strTitle + " " + m_stackReturnBackUIData.Count); * m_currPanelID = panelBase.PanelId; * * UIManager.ShowPanel(PanelID.TopBarPanel, data: panelBase.PanelInfo); * * if (m_fClosePanelTime > 0f) * { * Engine.Utility.TimerAxis.Instance().KillTimer(TIMERID, this); * m_fClosePanelTime = 0f; * } * }*/ CreateTabs(panelBase); }
public void ClosePanel(int id) { UIPanelBase panel = null; if (openedPanels.TryGetValue(id, out panel)) { openedPanels.Remove(id); ClosePanel(panel); } }
/// <summary> /// 调节当前显示面板的深度 /// </summary> /// <param name="panel"></param> public void AdjustPanelBaseDepth(UIPanelBase panel) { if (panel == null) { return; } int depth = GetTargetRootMaxDepth(panel); panel.UpdatePanelDepth(depth); }
/// <summary> /// 获取面板 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="panelId"></param> /// <returns></returns> public T GetPanel <T>(PanelID panelId) where T : UIPanelBase { UIPanelBase panel = GetPanel(panelId); if (null != panel && panel is T) { return(panel as T); } return(null); }
/// <summary> /// 得到CanvasGroup /// </summary> /// <param name="panel"></param> /// <returns></returns> private static CanvasGroup GetCanvasGroup(UIPanelBase panel) { var cg = panel.GetComponent <CanvasGroup>(); if (!cg) { cg = panel.gameObject.AddComponent <CanvasGroup>(); } return(cg); }
/// <summary> /// 获取panel /// </summary> /// <param name="panelId"></param> /// <returns></returns> public UIPanelBase GetPanel(PanelID panelId) { UIPanelBase pb = null; if (allPanels.TryGetValue((uint)panelId, out pb)) { return(pb); } return(null); }
//~~~~~~~~~~~~~~~~~~~~~~~渲染层级~~~~~~~~~~~~~~~~~~~~~~~~// /// <summary> /// 重设UI渲染层级 /// </summary> /// <param name="id"></param> public void ResetSortingOrder(int id) { GameObject obj = UIManager.Instance.Find(id); if (obj == null) { return; } UIPanelBase currView = obj.GetComponent <UIPanelBase>(); if (currView == null) { return; } currView.MaxSortingOrder = 0; int UILayerID = UIManager.Instance.GetUILayerID(id); GameObject layer = UILayerUtils.GetLayer(UILayerID).gameObject; int maxCanvasSortingOrder = GetMaxCanvasSortingOrder(layer); Canvas currCanvas = obj.GetComponent <Canvas>(); if (currCanvas == null) { currCanvas = obj.AddComponent <Canvas>(); } if (maxCanvasSortingOrder != -1) { currCanvas.overrideSorting = true; if (maxCanvasSortingOrder == 0) { currCanvas.sortingOrder = UILayerID * UIID.OrderLyaerInterval; currView.MaxSortingOrder = UILayerID * UIID.OrderLyaerInterval; } else { currCanvas.sortingOrder = maxCanvasSortingOrder + 1; currView.MaxSortingOrder = maxCanvasSortingOrder + 1; } } // 加射线 GraphicRaycaster cast = obj.GetComponent <GraphicRaycaster>(); if (cast == null) { cast = obj.AddComponent <GraphicRaycaster>(); } CanvasGroup canvasGroup = obj.GetComponent <CanvasGroup>(); if (canvasGroup == null) { canvasGroup = obj.AddComponent <CanvasGroup>(); } }
public override void Copy(SpriteRoot s, ControlCopyFlags flags) { base.Copy(s, flags); if (!(s is UIBtnLoadScene)) return; UIBtnLoadScene b = (UIBtnLoadScene)s; if ((flags & ControlCopyFlags.Settings) == ControlCopyFlags.Settings) { scene = b.scene; loadingPanel = b.loadingPanel; } }
// Called when the loading panel's transition ends. public void LoadSceneDelegate(UIPanelBase panel, EZTransition trans) { LoadScene(); }
public void OnSelectionChange() { bool somethingChanged = false; if (panel != null) { if (panel.gameObject != Selection.activeGameObject) { somethingChanged = true; } } else somethingChanged = true; if (somethingChanged) { if (Selection.activeGameObject != null) { panel = (UIPanelBase)Selection.activeGameObject.GetComponent(typeof(UIPanelBase)); selGO = Selection.activeGameObject; curTrans = 0; curTransElement = 0; } else { selGO = null; panel = null; } } Repaint(); }
/// <summary> /// Dismisses the currently showing panel, if any, /// in the direction specified. /// </summary> /// <param name="dir">The direction in which the panel is to be dismissed.</param> public void Dismiss(MENU_DIRECTION dir) { StartCoroutine("Start"); if (dir == MENU_DIRECTION.Auto) dir = MENU_DIRECTION.Backwards; SHOW_MODE mode = ((dir == MENU_DIRECTION.Forwards) ? (SHOW_MODE.DismissForward) : (SHOW_MODE.DismissBack)); if (curPanel != null) StartAndTrack(curPanel, mode); curPanel = null; // Only push on a null ref if there // isn't already one on the stack: if (breadcrumbs.Count > 0) if (breadcrumbs[breadcrumbs.Count - 1] != null) breadcrumbs.Add(null); }
/// <summary> /// Brings in the specified panel in a manner /// that portrays the menu moving in the direction /// determined by comparing the index of the /// current panel to the one being brought up. /// </summary> /// <param name="panel">Reference to the panel to bring up.</param> public void BringIn(UIPanelBase panel) { BringIn(panel, MENU_DIRECTION.Auto); }
/// <summary> /// Brings in the specified panel in a manner /// that portrays the menu moving in the /// specified direction. If "Auto" is specified /// for the direction, forward/backward is /// determined by comparing the index of the /// current panel to the one being brought up. /// </summary> /// <param name="panel">Reference to the panel to bring up.</param> /// <param name="dir">Direction the menu should appear to be moving. /// If "Auto" is specified, the direction is determined by comparing /// the index of the current panel to the one being brought up.</param> public void BringIn(UIPanelBase panel, MENU_DIRECTION dir) { StartCoroutine("Start"); SHOW_MODE dismissMode; SHOW_MODE bringInMode; if (curPanel == panel) return; // Nothing to do! if (dir == MENU_DIRECTION.Auto) { // See if we can determine the direction: if (curPanel != null) { // Forward if (curPanel.index <= panel.index) dir = MENU_DIRECTION.Forwards; else // Backward dir = MENU_DIRECTION.Backwards; } else // Assume forward: dir = MENU_DIRECTION.Forwards; } dismissMode = ((dir == MENU_DIRECTION.Forwards) ? (SHOW_MODE.DismissForward) : (SHOW_MODE.DismissBack)); bringInMode = ((dir == MENU_DIRECTION.Forwards) ? (SHOW_MODE.BringInForward) : (SHOW_MODE.BringInBack)); // Dismiss the current panel: if (curPanel != null) StartAndTrack(curPanel, dismissMode); // Bring in the next panel: curPanel = panel; breadcrumbs.Add(curPanel); #if UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5 || UNITY_4_6 || UNITY_4_7 || UNITY_4_8 || UNITY_4_9 if (deactivateAllButInitialAtStart && !curPanel.gameObject.activeInHierarchy) { curPanel.Start(); curPanel.gameObject.SetActive(true); } #else if (deactivateAllButInitialAtStart && !curPanel.gameObject.active) { curPanel.Start(); curPanel.gameObject.SetActiveRecursively(true); } #endif StartAndTrack(curPanel, bringInMode); }
public override void Copy(SpriteRoot s, ControlCopyFlags flags) { base.Copy(s, flags); if (!(s is UIPanelTab)) return; UIPanelTab b = (UIPanelTab)s; if ((flags & ControlCopyFlags.Settings) == ControlCopyFlags.Settings) { toggle = b.toggle; panelManager = b.panelManager; panel = b.panel; panelShowingAtStart = b.panelShowingAtStart; } if ((flags & ControlCopyFlags.State) == ControlCopyFlags.State) { Value = b.Value; } }
void Awake() { if (m_instance == null) m_instance = this; if(defaultPanel != null && initialPanel == null) initialPanel = defaultPanel; }
IEnumerator Start() { ScanChildren(); if (initialPanel != null) { curPanel = initialPanel; breadcrumbs.Add(curPanel); } if (circular) linearNavigation = true; if(deactivateAllButInitialAtStart) { // Wait a frame so the contents of the panels // are done Start()'ing, or else we'll get // unhidden stuff: yield return null; for (int i = 0; i<panels.Count; ++i) if (panels[i] != initialPanel && panels[i] != curPanel) panels[i].gameObject.SetActiveRecursively(false); } }
/// <summary> /// Brings in the specified panel in a manner /// that portrays the menu moving in the /// specified direction. If "Auto" is specified /// for the direction, forward/backward is /// determined by comparing the index of the /// current panel to the one being brought up. /// </summary> /// <param name="panel">Reference to the panel to bring up.</param> /// <param name="dir">Direction the menu should appear to be moving. /// If "Auto" is specified, the direction is determined by comparing /// the index of the current panel to the one being brought up.</param> public void BringIn(UIPanelBase panel, MENU_DIRECTION dir) { SHOW_MODE dismissMode; SHOW_MODE bringInMode; if (curPanel == panel) return; // Nothing to do! if(dir == MENU_DIRECTION.Auto) { // See if we can determine the direction: if (curPanel != null) { // Forward if (curPanel.index <= panel.index) dir = MENU_DIRECTION.Forwards; else // Backward dir = MENU_DIRECTION.Backwards; } else // Assume forward: dir = MENU_DIRECTION.Forwards; } dismissMode = ( (dir == MENU_DIRECTION.Forwards) ? (SHOW_MODE.DismissForward) : (SHOW_MODE.DismissBack) ); bringInMode = ( (dir == MENU_DIRECTION.Forwards) ? (SHOW_MODE.BringInForward) : (SHOW_MODE.BringInBack) ); // Dismiss the current panel: if (curPanel != null) curPanel.StartTransition(dismissMode); // Bring in the next panel: curPanel = panel; breadcrumbs.Add(curPanel); if (deactivateAllButInitialAtStart && !curPanel.gameObject.active) { curPanel.Start(); curPanel.gameObject.SetActiveRecursively(true); } curPanel.StartTransition(bringInMode); }
/// <summary> /// Moves the menu forward to the next panel /// in the sequence (determined by panel /// index). Automatically dismisses the /// currently displaying panel using the /// forward mode. /// </summary> /// <returns>True if the there are more panels /// after this one. False if this is the last /// panel, or if the menu was already at the end.</returns> public bool MoveForward() { int index = panels.IndexOf(curPanel); if (index >= panels.Count - 1) { // See if we should wrap to the beginning: if (!circular) { // See if we should advance past the end: if (advancePastEnd) { // Send away the current panel: if (curPanel != null) curPanel.StartTransition(SHOW_MODE.DismissForward); curPanel = null; // Don't add more than one null on the stack: if(breadcrumbs.Count > 0) { if (breadcrumbs[breadcrumbs.Count - 1] != null) breadcrumbs.Add(null); } else breadcrumbs.Add(null); } return false; // We're already at the end } else index = -1; // Wrap back to the beginning } // Send away the current panel: if (curPanel != null) curPanel.StartTransition(SHOW_MODE.DismissForward); // Bring in the next panel: ++index; curPanel = panels[index]; breadcrumbs.Add(curPanel); if (deactivateAllButInitialAtStart && !curPanel.gameObject.active) { curPanel.Start(); curPanel.gameObject.SetActiveRecursively(true); } curPanel.StartTransition(SHOW_MODE.BringInForward); if (index >= panels.Count - 1 && !circular) return false; else return true; }
/// <summary> /// Moves the menu forward to the next panel /// in the sequence (determined by panel /// index). Automatically dismisses the /// currently displaying panel using the /// forward mode. /// </summary> /// <returns>True if the there are more panels /// after this one. False if this is the last /// panel, or if the menu was already at the end.</returns> public bool MoveForward() { StartCoroutine("Start"); int index = panels.IndexOf(curPanel); if (index >= panels.Count - 1) { // See if we should wrap to the beginning: if (!circular) { // See if we should advance past the end: if (advancePastEnd) { // Send away the current panel: if (curPanel != null) StartAndTrack(curPanel, SHOW_MODE.DismissForward); curPanel = null; // Don't add more than one null on the stack: if (breadcrumbs.Count > 0) { if (breadcrumbs[breadcrumbs.Count - 1] != null) breadcrumbs.Add(null); } else breadcrumbs.Add(null); } return false; // We're already at the end } else index = -1; // Wrap back to the beginning } // Send away the current panel: if (curPanel != null) StartAndTrack(curPanel, SHOW_MODE.DismissForward); // Bring in the next panel: ++index; curPanel = panels[index]; breadcrumbs.Add(curPanel); #if UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5 || UNITY_4_6 || UNITY_4_7 || UNITY_4_8 || UNITY_4_9 if (deactivateAllButInitialAtStart && !curPanel.gameObject.activeInHierarchy) { curPanel.Start(); curPanel.gameObject.SetActive(true); } #else if (deactivateAllButInitialAtStart && !curPanel.gameObject.active) { curPanel.Start(); curPanel.gameObject.SetActiveRecursively(true); } #endif StartAndTrack(curPanel, SHOW_MODE.BringInForward); if (index >= panels.Count - 1 && !circular) return false; else return true; }
/// <summary> /// Moves the menu back to the previous panel /// in the sequence (determined by panel /// index). Automatically dismisses the /// currently displaying panel using the /// "back" mode. /// </summary> /// <returns>True if the there are more panels /// before this one. False if this is the first /// panel, or if the menu was already at the /// beginning.</returns> public bool MoveBack() { // If this isn't a linear menu, use our history // to go backward: if (!linearNavigation) { // See if we're at the beginning: if (breadcrumbs.Count <= 1) { if (advancePastEnd) { // Send away the current panel: if (curPanel != null) StartAndTrack(curPanel, SHOW_MODE.DismissBack); curPanel = null; // Don't add more than one null on the stack: if (breadcrumbs.Count > 0) { if (breadcrumbs[breadcrumbs.Count - 1] != null) breadcrumbs.Add(null); } else breadcrumbs.Add(null); } return false; // We're at the beginning } // Go back in our history: if (breadcrumbs.Count != 0) breadcrumbs.RemoveAt(breadcrumbs.Count - 1); // Send away the current panel: if (curPanel != null) StartAndTrack(curPanel, SHOW_MODE.DismissBack); // Bring in the previous panel: if (breadcrumbs.Count > 0) curPanel = breadcrumbs[breadcrumbs.Count - 1]; if (curPanel != null) { #if UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5 || UNITY_4_6 || UNITY_4_7 || UNITY_4_8 || UNITY_4_9 if (deactivateAllButInitialAtStart && !curPanel.gameObject.activeInHierarchy) { curPanel.Start(); curPanel.gameObject.SetActive(true); } #else if (deactivateAllButInitialAtStart && !curPanel.gameObject.active) { curPanel.Start(); curPanel.gameObject.SetActiveRecursively(true); } #endif StartAndTrack(curPanel, SHOW_MODE.BringInBack); } // Return false if we've reached the beginning: if (breadcrumbs.Count <= 1) return false; else return true; } else // Else this is a linear menu, so just go back to the previous panel in our array { int index = panels.IndexOf(curPanel); // If we're at the first index: if (index <= 0) { if (!circular) { if (advancePastEnd) { // Send away the current panel: if (curPanel != null) StartAndTrack(curPanel, SHOW_MODE.DismissBack); curPanel = null; } return false; // We're already at the beginning } else { // Wrap back to the end: index = panels.Count; } } // Send away the current panel: if (curPanel != null) StartAndTrack(curPanel, SHOW_MODE.DismissBack); // Bring in the previous panel: --index; curPanel = panels[index]; #if UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5 || UNITY_4_6 || UNITY_4_7 || UNITY_4_8 || UNITY_4_9 if (deactivateAllButInitialAtStart && !curPanel.gameObject.activeInHierarchy) { curPanel.Start(); curPanel.gameObject.SetActive(true); } #else if (deactivateAllButInitialAtStart && !curPanel.gameObject.active) { curPanel.Start(); curPanel.gameObject.SetActiveRecursively(true); } #endif StartAndTrack(curPanel, SHOW_MODE.BringInBack); if (index <= 0 && !circular) return false; else return true; } }
/// <summary> /// Same as BringIn(...), but skips the panel's transition, fast-forwarding /// it instantly to its end state. See the corresponding BringIn() entry for more details. /// </summary> /// <param name="panel">Reference to the panel to bring up.</param> /// <param name="dir">Direction the menu should appear to be moving. /// If "Auto" is specified, the direction is determined by comparing /// the index of the current panel to the one being brought up.</param> public void BringInImmediate(UIPanelBase panel, MENU_DIRECTION dir) { StartCoroutine("Start"); UIPanelBase prevPanel = curPanel; EZTransition trans; // Get the transition directions: if (dir == MENU_DIRECTION.Auto) { // See if we can determine the direction: if (curPanel != null) { // Forward if (curPanel.index <= panel.index) dir = MENU_DIRECTION.Forwards; else // Backward dir = MENU_DIRECTION.Backwards; } else // Assume forward: dir = MENU_DIRECTION.Forwards; } SHOW_MODE dismissMode = ((dir == MENU_DIRECTION.Forwards) ? (SHOW_MODE.DismissForward) : (SHOW_MODE.DismissBack)); SHOW_MODE bringInMode = ((dir == MENU_DIRECTION.Forwards) ? (SHOW_MODE.BringInForward) : (SHOW_MODE.BringInBack)); // Do the bring-in: BringIn(panel, dir); // End the transitions early: if (prevPanel != null) { trans = prevPanel.GetTransition(dismissMode); trans.End(); } if (curPanel != null) { trans = curPanel.GetTransition(bringInMode); trans.End(); } }
// Compares panel indices so they can be sorted this way. public static int CompareIndices(UIPanelBase a, UIPanelBase b) { return a.index - b.index; }
/// <summary> /// Same as BringIn(...), but skips the panel's transition, fast-forwarding /// it instantly to its end state. See the corresponding BringIn() entry for more details. /// </summary> /// <param name="panel">Reference to the panel to bring up.</param> public void BringInImmediate(UIPanelBase panel) { BringInImmediate(panel, MENU_DIRECTION.Auto); }
static void CopyPanel(UIPanelBase panel) { transList = new EZTransitionList[1]; transList[0] = new EZTransitionList(); panel.Transitions.CopyToNew(transList[0], true); transList[0].MarkAllInitialized(); PatStuff.ScreenLog.AddMessage("Transitions Copied"); }
public void OnGUI() { bool needRepaint = false; isDirty = false; if (restarted) { selGO = null; panel = null; OnSelectionChange(); restarted = false; } // See if we need to update our selection: if (Selection.activeGameObject != selGO) OnSelectionChange(); //#if UNITY_IPHONE && !(UNITY_3_0 || UNITY_3_1 || UNITY_3_2 || UNITY_3_3 || UNITY_3_4 || UNITY_3_5 || UNITY_3_6 || UNITY_3_7 || UNITY_3_8 || UNITY_3_9 || UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5 || UNITY_4_6 || UNITY_4_7 || UNITY_4_8 || UNITY_4_9) if(Selection.activeGameObject != null) panel = (UIPanelBase)Selection.activeGameObject.GetComponent(typeof(UIPanelBase)); //#endif // Bailout if we don't have valid values: if (panel == null) { PrintNoSelectMsg(); return; } //----------------------------------------- // Draw our transition stuff: //----------------------------------------- if (panel.Transitions != null) if (panel.Transitions.list != null) if (panel.Transitions.list.Length > 0) DoTransitionStuff(); GUILayout.Space(10f); // Set dirty if anything changed: if (isDirty) { EditorUtility.SetDirty(panel); } if (needRepaint) Repaint(); }
static void PastePanel(UIPanelBase panel) { transList[0].CopyTo(panel.Transitions, true); transList[0].MarkAllInitialized(); EditorUtility.SetDirty(panel.gameObject); PatStuff.ScreenLog.AddMessage("Transitions Pasted"); }
IEnumerator Start() { if (m_started) yield break; m_started = true; ScanChildren(); if (initialPanel != null) { curPanel = initialPanel; breadcrumbs.Add(curPanel); } if (circular) linearNavigation = true; if (deactivateAllButInitialAtStart) { // Wait a frame so the contents of the panels // are done Start()'ing, or else we'll get // unhidden stuff: yield return null; for (int i = 0; i < panels.Count; ++i) if (panels[i] != initialPanel && panels[i] != curPanel) #if UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5 || UNITY_4_6 || UNITY_4_7 || UNITY_4_8 || UNITY_4_9 panels[i].gameObject.SetActive(false); #else panels[i].gameObject.SetActiveRecursively(false); #endif } }
protected void DecrementTransitioningPanels(UIPanelBase p, EZTransition t) { --transitioningPanelCount; }
// Starts a panel transitioning and tracks it protected void StartAndTrack(UIPanelBase p, SHOW_MODE mode) { p.StartTransition(mode); // See if it didn't quit immediately: if (p.IsTransitioning) { p.AddTempTransitionDelegate(DecrementTransitioningPanels); ++transitioningPanelCount; } }
// Called when the loading panel's transition ends. public void LoadSceneDelegate(UIPanelBase panel, EZTransition trans) { StartCoroutine(LoadScene()); }
void StopLoading(UIPanelBase panel, EZTransition transition) { Flow.game_native.stopLoading(); }