public static Command ShowCmd(E_UIType _uiType, System.Action <BaseUI> listener, bool _isCloseOtherUIs, bool _createCanCall, params object[] _param) { Command cmd = new Command(Command.CmdType.Show, _uiType, _param); cmd.CreateCanCall = _createCanCall; cmd.Listener = listener; cmd.IsCloseOtherUIs = _isCloseOtherUIs; return(cmd); }
public BaseUI GetUIByType(E_UIType uiType) { //关闭其他ui if (_dicUI.ContainsKey(uiType)) { return(_dicUI[uiType]); } return(null); }
public static Command ShowCmd_LUA(E_UIType _uiType, LuaFunction lua_fun, bool _isCloseOtherUIs, bool _createCanCall, params object[] _param) { Command cmd = new Command(Command.CmdType.Show, _uiType, _param); cmd.CreateCanCall = _createCanCall; cmd.lua_fun = lua_fun; cmd.IsCloseOtherUIs = _isCloseOtherUIs; return(cmd); }
public static Command CreateAndShowCmd_LUA(E_UIType uiType, System.Type type, LuaFunction lua_fun, bool isCloseOtherUIs, bool createCanCall, params object[] param) { Command cmd = new Command(Command.CmdType.CreateAndShow, uiType, param); cmd.lua_fun = lua_fun; cmd.MonoType = type; cmd.CreateCanCall = createCanCall; cmd.IsCloseOtherUIs = isCloseOtherUIs; cmd.bLuaBehaviour = true; return(cmd); }
public static Command CreateAndShowCmd(E_UIType uiType, System.Type type, System.Action <BaseUI> listener, bool isCloseOtherUIs, bool createCanCall, params object[] param) { Command cmd = new Command(Command.CmdType.CreateAndShow, uiType, param); cmd.Listener = listener; cmd.MonoType = type; cmd.CreateCanCall = createCanCall; cmd.IsCloseOtherUIs = isCloseOtherUIs; cmd.bLuaBehaviour = false; return(cmd); }
/// <summary> /// 给定view是否正在显示 /// </summary> /// <param name="view"></param> /// <returns></returns> public bool IsViewShowing(E_UIType view) { int order = GetLargestOrder(); if (uiCp.canvases.ContainsKey(view)) { return(uiCp.canvases[view].sortingOrder == order); } return(false); }
private void AddUI(BaseUI ui) { E_UIType uiType = ui.GetUIType(); if (_dicUI.ContainsKey(uiType)) { _dicUI[uiType] = ui; } else { _dicUI.Add(uiType, ui); } }
/// <summary> /// Close view /// </summary> /// <param name="type"></param> public void CloseUI(E_UIType type) { int index = GetViewTypeIndex(type); if (index != -1) { var ui = GetUI(index); showSystem.CloseView(ui); RemoveUI(index); CheckCanvasUsable(index); } }
public GameObject GetCanvas(E_UIType type) { GameObject _canvasObj; if (uiCp.canvases.ContainsKey(type)) { _canvasObj = uiCp.canvases[type].gameObject; } else { _canvasObj = new GameObject(type.ToString() + "_canvas"); GameObject.DontDestroyOnLoad(_canvasObj); Canvas _canvas = _canvasObj.AddComponent <Canvas>(); _canvas.renderMode = RenderMode.ScreenSpaceCamera; _canvas.pixelPerfect = false; if (_canvas.worldCamera == null) { _canvas.worldCamera = Camera.main; } // Set oreder, get largest order int _order = 0; switch (type) { case E_UIType.PopupUI: _order = 100; break; default: _order = GetLargestOrder() + 1; break; } _canvas.sortingOrder = _order; CanvasScaler _scaler = _canvasObj.AddComponent <CanvasScaler>(); _scaler.uiScaleMode = CanvasScaler.ScaleMode.ScaleWithScreenSize; _scaler.referenceResolution = new Vector2(Screen.width, Screen.height); _scaler.screenMatchMode = CanvasScaler.ScreenMatchMode.Expand; _canvasObj.AddComponent <GraphicRaycaster>(); uiCp.canvases.Add(type, _canvas); } return(_canvasObj); }
/// <summary> /// 得到最上曾的canvas /// </summary> /// <returns></returns> public GameObject GetUperCanvas(List <E_UIType> exceptType = null) { int _order = -1; E_UIType index = uiCp.canvases.Keys.First(); foreach (var _c in uiCp.canvases.Keys) { if (uiCp.canvases[_c].sortingOrder > _order && (exceptType == null || exceptType.Contains(_c) == false)) { if (uiCp.canvases[_c].transform.childCount > 0) { index = _c; _order = uiCp.canvases[_c].sortingOrder; } } } return(uiCp.canvases[index].gameObject); }
/// <summary> /// Open view with type /// </summary> public GameObject OpenUI(E_UIType type, bool singleton = false) { GameObject _view; // 重新排序 ResetOrder(); _view = CreateUI(type, singleton); // pop to front PopToFront(type); showSystem.ShowView(_view); uiCp.lastMainView = type; uiCp.openView = type; return(_view); }
GameObject CreateUI(E_UIType type, bool isSingleton = false) { int index = GetViewTypeIndex(type); if ((isSingleton && index == -1) || !isSingleton) { GameObject canvasObj = GetCanvas(type); // Instantiate // var prefab = poolSystem.Get((int)type); // if (prefab == null) // { // prefab = Resources.Load<GameObject>(uiCp.UI_PATH + type.ToString()); // poolSystem.Push((int)type, prefab); // } // var ui = GameObject.Instantiate(prefab, canvasObj.transform); var ui = UISystemUtil.CreateUIFromPrefab(poolSystem, (int)type, uiCp.UI_PATH + type.ToString(), canvasObj.transform); // Add to container if (index == -1) { uiCp.views.Add(new Views(type, new GameObject[] { ui })); } else { uiCp.views[index].uis.Add(ui); } index = uiCp.views.Count - 1; } return(GetUI(index)); }
public void ShowUIAndCloseOthers_LUA(E_UIType uiType, LuaFunction func = null, params object[] param) { ShowUI_LUA(uiType, func, true, true, param); _layerCurrentIndex = 0; }
int GetViewTypeIndex(E_UIType type) { return(uiCp.views.FindIndex(v => v.uiType == type)); }
public void DestroyUI(E_UIType uiType) { _listCmd.Add(Command.DestroyCmd(uiType)); }
public void HideUI(E_UIType uiType) { _listCmd.Add(Command.HideCmd(uiType)); }
public GameObject ReopenView(E_UIType type) { CloseUI(type); return(OpenUI(type)); }
private Command(CmdType _cmdType, E_UIType _uiType, params object[] _params) { CommandType = _cmdType; UIType = _uiType; Params = _params; }
public static Command DestroyCmd(E_UIType _uiType) { Command cmd = new Command(Command.CmdType.Destroy, _uiType); return(cmd); }
public static Command HideCmd(E_UIType _uiType) { Command cmd = new Command(Command.CmdType.Hide, _uiType); return(cmd); }
/// <summary> /// 打开ui,并关闭其他所有 /// </summary> /// <param name="uiType">UI类型</param> /// <param name="typeMono">绑定mono脚本类型</param> /// <param name="listener">回调监听</param> /// <param name="createCanCall">只是创建ui时是否回调</param> /// <param name="param">参数</param> public void ShowUIAndCloseOthers(E_UIType uiType, System.Type typeMono, System.Action <BaseUI> listener = null, bool createCanCall = false, params object[] param) { ShowUI(uiType, typeMono, listener, true, createCanCall = false, param); _layerCurrentIndex = 0; }
public static Command CreateCmd(System.Type _type, E_UIType _uiType, System.Action <BaseUI> _listener) { Command cmd = new Command(Command.CmdType.Create, _uiType, _type, _listener); return(cmd); }
public static Command CreateCmd_LUA(System.Type _type, E_UIType _uiType, LuaFunction _lua_fun) { Command cmd = new Command(Command.CmdType.Create, _uiType, _type, _lua_fun); return(cmd); }
public Views(E_UIType type, GameObject[] ui) { uiType = type; uis = new List <GameObject>(ui); }
/// <summary> /// 创建ui,不显示 /// </summary> /// <param name="uiType">User interface type.</param> /// <param name="type">Type.</param> /// <param name="listener">Listener.</param> public void CreateUI(E_UIType uiType, System.Type monoType, System.Action <BaseUI> listener) { _listCmd.Add(Command.CreateCmd(monoType, uiType, listener)); }