/// <summary> /// 消息窗口的显示,目前支持3种类型 /// </summary> public void ShowMessageBox(string msg, MessageBoxType type, MsgBoxCallBack callback = null) { string wndPath = wndResDict [WindowID.Msgbox]; GameObject prefab = Resources.Load <GameObject> ("UIPrefab/Msgbox"); if (prefab != null) { GameObject clone = (GameObject)GameObject.Instantiate(prefab); UnityTools.AddChildToTarget(msgBoxRoot.transform, clone.transform); UIMessageBox msgBox = clone.GetComponent <UIMessageBox> (); } }
private void RealShow(WindowID windowId, bool bAppend) { string wndPath = wndResDict [windowId]; GameObject prefab = null; if (GameManager.Instance.ResFrom != ResourceFrom.Bundle) { prefab = ResourceManager.LoadResource("UIPrefab/" + windowId.ToString()) as GameObject; } else { prefab = ResourceManager.GetInstance().LoadAsset(wndPath, windowId.ToString()); } if (prefab != null) { GameObject clone = (GameObject)GameObject.Instantiate(prefab); UnityTools.AddChildToTarget(wndRoot.transform, clone.transform); UIWndBase wnd = clone.GetComponent <UIWndBase> (); wnd.status = WindowStatus.Active; if (curShowWnd != null) { wnd.preWndID = curShowWnd.wndID; } wnd.wndID = windowId; if (bAppend) { if (backStack.Count == 0) { backStack.Push(curShowWnd); } curShowWnd = wnd; backStack.Push(curShowWnd); AdjustAlpha(); } else { curShowWnd = wnd; HideAllCach(); BreakBackStack(); } cacheWndDict.Add(windowId, curShowWnd); curShowWnd.AdjustAlpha(1.0f); CheckCach(); wnd.Refresh(); } }
private void CreateFightPopup(string content, Vector3 startpoint = default(Vector3)) { string prefabStr = "FightTip"; GameObject tipObj = Resources.Load("tips/" + prefabStr) as GameObject; if (null == tipObj) { return; } tipObj = GameObject.Instantiate(tipObj) as GameObject; UnityTools.AddChildToTarget(UIManager.Intance.TipRoot.transform, tipObj.transform); PopTip pop = tipObj.GetComponent <PopTip>(); pop.m_startPoint = startpoint; pop.OnInit(ShowNextTip, TipShowNextTime); pop.ShowTip(content, OnTipOver); }
void Awake() { instance = this; wndRoot = new GameObject("WndRoot"); msgBoxRoot = new GameObject("MsgBoxRoot"); TipRoot = new GameObject("TipRoot"); EffectRoot = new GameObject("EffectRoot"); UnityTools.AddChildToTarget(root.transform, wndRoot.transform); UnityTools.AddChildToTarget(root.transform, msgBoxRoot.transform); UnityTools.AddChildToTarget(root.transform, EffectRoot.transform); UnityTools.AddChildToTarget(root.transform, TipRoot.transform);; //初始化窗口预制体资源 foreach (WindowID id in Enum.GetValues(typeof(WindowID))) { // Debug.Log (id); wndResDict.Add(id, AppConst.ui_prefix + id.ToString()); } }