//同步加载窗口 public UIWindow loadWindowSync(string winName, string srcName, UI_LAYER layer, UI_TYPE ui_type) { AssetBundleInfo abInfo = AssetBundleManager.Instance.LoadSync(srcName); GameObject go = GameObject.Instantiate(abInfo.mainObject) as GameObject; UIWindow win = setWindow(winName, go, layer, ui_type); return(win); }
public void setLayer(GameObject go, UI_LAYER layer) { UIWidget[] uiWindgets = go.GetComponentsInChildren <UIWidget>(true); foreach (UIWidget widget in uiWindgets) { widget.depth += (int)layer; } UIPanel panel = go.GetComponent <UIPanel>(); UIPanel[] panels = go.GetComponentsInChildren <UIPanel>(true); foreach (UIPanel p in panels) { p.depth += (int)layer; } go.transform.localPosition = new Vector3(0, 0, 0 - (int)layer); }
public void ShowPanel <T>(string name, UI_LAYER layer = UI_LAYER.Bottom, UnityAction <T> callBack = null) where T : BasePanel { if (panelDic.ContainsKey(name)) { panelDic[name].Show(); callBack?.Invoke(panelDic[name] as T); return; } ResMgr.Instance.LoadAsyn <GameObject>("UI/" + name, (obj) => { Transform father = null; switch (layer) { case UI_LAYER.Bottom: father = bottom; break; case UI_LAYER.Middle: father = midlle; break; case UI_LAYER.Top: father = top; break; case UI_LAYER.System: father = system; break; } obj.transform.SetParent(father); obj.transform.localPosition = Vector3.zero; obj.transform.localScale = Vector3.one; (obj.transform as RectTransform).offsetMax = Vector3.zero; (obj.transform as RectTransform).offsetMin = Vector3.zero; T panel = obj.GetComponent <T>(); panel.Show(); callBack?.Invoke(panel); panelDic.Add(name, panel); }); }
public UIWindow setWindow(string name, GameObject go, UI_LAYER layer, UI_TYPE ui_type) { switch (ui_type) { case UI_TYPE.COMMON: go.transform.parent = commonUIAnchor_.transform; break; case UI_TYPE.LOGIN: go.transform.parent = loginUIAnchor_.transform; go.transform.localPosition = Vector3.zero; break; case UI_TYPE.MAIN: go.transform.parent = mainUIPanel_.transform; break; case UI_TYPE.Movie: go.transform.parent = moviePanel_.transform; break; } UIWindow win = go.GetComponent <UIWindow>(); if (win != null) { win.windowName = name; if (!windowList_.ContainsKey(name)) { windowList_.Add(name, win); } else { windowList_[name] = win; } } setLayer(go, layer); go.SetActive(false); go.transform.localScale = new Vector3(1, 1, 1); go.name = name; return(win); }
public void SetLayer(UI_LAYER layer) { UILayer = layer; }
public void show(string str, MsgBox.ShowType type = ShowType.OK, MsgBox.CallBack callback = null, UI_LAYER layer = UI_LAYER.COMMON_UI, MsgBox.CancelCallBack cancelCallback = null) { if (_tip != null) { _tip.text = str; } if (string.IsNullOrEmpty(str)) { TyCrashReport.reportException(new System.Exception(), "msgbox content is empty"); } if (callback_ != null) { base.hide(); _OpenAgain = true; } gameObject.SetActive(true); { gameObject.transform.localPosition = new Vector3(0, 0, -(int)layer); } UIPanel panel = GetComponent <UIPanel>(); if (panel != null) { panel.depth = (int)layer; } setWinAnimIgnoreTimeScale(Time.timeScale != 1);//如果时间缩放不为1,则需要忽略缩放 base.show(); hideAll(); callback_ = callback; _cancelCallBack = cancelCallback; if (type == ShowType.OK) { _goOK.SetActive(true); } else if (type == ShowType.YesCancel) { _goYesCancel.SetActive(true); } }
static public GameObject addGameObjectToWindowStatic(GameObject parent, GameObject myObj, UI_LAYER layer, string name = "", bool needCopy = true) { GameObject go = myObj; if (needCopy) { go = GameObject.Instantiate(myObj) as GameObject; } if (go != null) { go.transform.parent = parent.transform; UIWidget[] uiWindgets = go.GetComponentsInChildren <UIWidget>(true); foreach (UIWidget widget in uiWindgets) { widget.depth += (int)layer; } go.transform.localPosition = new Vector3(0, 0, -10); go.transform.localScale = new Vector3(1, 1, 1); } return(go); }
static public GameObject addPrefebToWindowStatic(GameObject parent, string path, UI_LAYER layer, string name = "") { GameObject go = RG_Utils.loadPrefeb(name, path); if (go != null) { go.transform.parent = parent.transform; UIWidget[] uiWindgets = go.GetComponentsInChildren <UIWidget>(true); foreach (UIWidget widget in uiWindgets) { widget.depth += (int)layer; } go.transform.localPosition = new Vector3(0, 0, -10); go.transform.localScale = new Vector3(1, 1, 1); } return(addGameObjectToWindowStatic(parent, go, layer, name, false)); }
public GameObject addPrefebToWindow(GameObject parent, string path, UI_LAYER layer, string name = "") { return(addPrefebToWindowStatic(parent, path, layer, name)); }
public void addToLoadingList(string name, string path, string resName, bool isInAssetList, UI_LAYER layer, UI_TYPE ui_type) { WindowLoadingData data = new WindowLoadingData(); data.name = name; data.path = path; if (isInAssetList) { data.resName = resName; } data.layer = layer; data.ui_type = ui_type; _loadList.Add(name, data); }