public void Close(SUIRoot _uiRoot, int _id) { AlertData data1 = GetFirstUsed(); AlertData data2 = null; for (int i = 0; i < m_alertStack.Count; i++) { if (_id == m_alertStack[i].id) { if (m_alertStack[i].uiRoot != _uiRoot) { Debug.LogError(" 关闭出错,该id不可被该场景控制。"); return; } data2 = m_alertStack[i]; m_alertStack.RemoveAt(i); break; } } if (data1 == data2) { //刷新显示 ShowAlertUI(); } }
/// <summary> /// 刷新提示框 /// </summary> /// <param name="_uiroot">当前场景的UIRoot</param> /// <param name="_state">1: 开启 2:隐藏 3:关闭 </param> public void Refresh(SUIRoot _uiroot, int _state) { switch (_state) { case 1: case 2: foreach (AlertData data in m_alertStack) { if (data.uiRoot == _uiroot) { data.state = _state; } } break; case 3: for (int i = m_alertStack.Count - 1; i >= 0; i--) { if (m_alertStack[i].uiRoot == _uiroot) { m_alertStack.RemoveAt(i); } } break; } //刷新界面中的对话框 ShowAlertUI(); }
/// <summary> /// 提示框 /// </summary> /// <param name="_uiroot">当前场景的Uiroot</param> /// <param name="title">标题</param> /// <param name="message">提示内容</param> /// <param name="but1Name">按钮1名称</param> /// <param name="but1CallBack">回调函数</param> /// <param name="but2Name">按钮2名称</param> /// <param name="but2CallBack">按钮2的回调函数</param> /// <param name="isShowExite">是否显示退出按钮</param> /// <returns>该提示框的ID号</returns> public int ShowAlert(SUIRoot _uiroot, string title, string message, string but1Name, Callback but1CallBack, string but2Name = null, Callback but2CallBack = null, bool isShowExite = false) { //关闭所有3D空间的操作 //MySkyInputEvent.instance.Pause(true); AlertData data = new AlertData(); data.uiRoot = _uiroot; data.title = title; data.message = message; data.okCallback = but1CallBack; data.okName = but1Name; data.cancelCallback = but2CallBack; data.cancelName = but2Name; data.id = m_id++; data.isShowExite = isShowExite; if (but2Name != null) { data.buttonNumber = 2; } else { data.buttonNumber = 1; } //添加提示框 m_alertStack.Insert(0, data); //显示提示框 ShowAlertUI(); return(data.id); }