コード例 #1
0
    static void AddUI(UIWindowBase UI)
    {
        if (!s_UIs.ContainsKey(UI.name))
        {
            s_UIs.Add(UI.name, new List <UIWindowBase>());
        }

        s_UIs[UI.name].Add(UI);

        UI.Show();
    }
コード例 #2
0
ファイル: UIManager.cs プロジェクト: boy3050/BetterFramework
    public virtual T GetWindowScript <T>(int id) where T : UIWindowBase
    {
        UIWindowBase baseWindow = GetWindow(id);

        if (baseWindow == null)
        {
            return(null);
        }

        return(baseWindow as T);
    }
コード例 #3
0
 /// <summary>
 /// 正常打开
 /// </summary>
 /// <param name="windowBase"></param>
 /// <param name="isOpen"></param>
 private void ShowNormal(UIWindowBase windowBase, bool isOpen)
 {
     if (isOpen)
     {
         NGUITools.SetActive(windowBase.gameObject, true);
     }
     else
     {
         DestroyWindow(windowBase);
     }
 }
コード例 #4
0
    /// <summary>
    /// 添加UI
    /// </summary>
    /// <param name="UI"></param>
    private static void AddUI(UIWindowBase UI)
    {
        if (!m_curShowUIs.ContainsKey(UI.name))
        {
            m_curShowUIs.Add(UI.name, new List <UIWindowBase>());
        }

        m_curShowUIs[UI.name].Add(UI);

        UI.Show();
    }
コード例 #5
0
 static bool GetIsExitsHide(UIWindowBase l_UI)
 {
     if (!s_hideUIs.ContainsKey(l_UI.name))
     {
         return(false);
     }
     else
     {
         return(s_hideUIs[l_UI.name].Contains(l_UI));
     }
 }
コード例 #6
0
    /// <summary>
    /// 加入隐藏列表,并且隐藏
    /// </summary>
    /// <param name="UI"></param>
    private static void AddHideUI(UIWindowBase UI)
    {
        if (!m_hideUIs.ContainsKey(UI.name))
        {
            m_hideUIs.Add(UI.name, new List <UIWindowBase>());
        }

        m_hideUIs[UI.name].Add(UI);

        UI.Hide();
    }
コード例 #7
0
        /// <summary>
        /// 清除对UI的操作
        /// </summary>
        /// <param name="ui"></param>
        protected virtual void ClearGuideBehaveByUI(UIWindowBase ui)
        {
            //清除高亮
            ui.ClearGuideModel();

            //清除特效
            m_guideWindowBase.ClearEffect();

            //清除手指
            m_guideWindowBase.HideAllGuideUI();
        }
コード例 #8
0
    public bool IsOpenning(UIWindowEnum name)
    {
        UIWindowBase WinBase = null;

        if (winLoadedDict.TryGetValue((int)name, out WinBase))
        {
            return(WinBase.gameObject.activeSelf);
        }

        return(false);
    }
コード例 #9
0
 /// <summary>
 /// 注册ui
 /// </summary>
 /// <param name="window"></param>
 /// <param name="uiName"></param>
 /// <param name="uiObj"></param>
 public void RegistUI(UIWindowBase UIWindowBase, Dictionary <string, List <GameObject> > uiDict)
 {
     if (_uiList.ContainsKey(UIWindowBase))
     {
         Debug.LogError("存在相同UIWindowBase" + UIWindowBase.name);
     }
     else
     {
         _uiList.Add(UIWindowBase, uiDict);
     }
 }
コード例 #10
0
 /// <summary>
 /// 某个UI是否在隐藏中
 /// </summary>
 /// <param name="UI"></param>
 /// <returns></returns>
 private static bool GetIsExitsHide(UIWindowBase UI)
 {
     if (!m_hideUIs.ContainsKey(UI.name))
     {
         return(false);
     }
     else
     {
         return(m_hideUIs[UI.name].Contains(UI));
     }
 }
コード例 #11
0
 static bool GetIsExits(UIWindowBase UI)
 {
     if (!s_UIs.ContainsKey(UI.name))
     {
         return(false);
     }
     else
     {
         return(s_UIs[UI.name].Contains(UI));
     }
 }
コード例 #12
0
ファイル: WindowUIMgr.cs プロジェクト: WuHaiqiang/MMOPRG
    /// <summary>
    /// 打开窗口
    /// </summary>
    /// <param name="type">窗口类型</param>
    /// <returns></returns>
    public GameObject OpenWindow(WindowUIType type)
    {
        if (type == WindowUIType.None)
        {
            return(null);
        }
        GameObject obj = null;

        //如果窗口不存在
        if (!m_DicWindow.ContainsKey(type))
        {
            //枚举的名称要和预设的名称对应
            obj = ResourcesMgr.Instance.Load(ResourcesMgr.ResourceType.UIWindow, string.Format("pan{0}", type.ToString()), cache: true);
            if (obj == null)
            {
                return(null);
            }
            UIWindowBase windowBase = obj.GetComponent <UIWindowBase>();
            if (windowBase == null)
            {
                return(null);
            }

            m_DicWindow.Add(type, windowBase);
            windowBase.CurrentUIType = type;

            Transform transParent = null;

            switch (windowBase.containerType)
            {
            case WindowUiContainerType.Center:
                transParent = SceneUIMgr.Instance.CurrentUIScene.Container_Center;
                break;

            default:
                break;
            }

            obj.transform.parent        = transParent;
            obj.transform.localPosition = Vector3.zero;
            obj.transform.localScale    = Vector3.one;
            NGUITools.SetActive(obj, false);

            StartShowWindow(windowBase, true);
        }
        else
        {
            obj = m_DicWindow[type].gameObject;
        }
        //层级管理
        LayerUIMgr.Instance.SetLayer(obj);
        return(obj);
    }
コード例 #13
0
    public void CloseWindow(UIWindowBase UIWindowBase, bool closeAnim = true, bool beForce = false, UICallBack uiCallBack = null, params object[] objs)
    {
        if (_windowStack.Count <= 0)
        {
            return;
        }
        var window = _windowStack.Peek();

        if (window == UIWindowBase)
        {
            window = _windowStack.Pop();
        }
        else
        {
            string windowName = UIWindowBase.name;
            window = _windowDict[windowName] as UIWindowBase;
            if (window.Status == UIStatus.Close)
            {
                return;
            }
        }
        window.Status = UIStatus.Close;
        if (closeAnim)
        {
            if (uiCallBack == null)
            {
                uiCallBack = window.OnClose;
            }
            else
            {
                uiCallBack += window.OnClose;
            }
            window.StartCoroutine(window.StartCloseAnim(uiCallBack, objs));
        }
        else
        {
            window.OnClose();
            if (uiCallBack != null)
            {
                uiCallBack(objs);
            }
        }

        if (!beForce && _windowStack.Count > 0)
        {
            window.OnLostFocus();
            var curTopWindow = _windowStack.Peek();
            if (curTopWindow != null)
            {
                curTopWindow.OnFocus();
            }
        }
    }
コード例 #14
0
ファイル: UIManager.cs プロジェクト: boy3050/BetterFramework
    private IEnumerator DestoryOtherWindowCor()
    {
        yield return(new WaitForEndOfFrame());

        for (int i = 0; i < removedKey.Count; i++)
        {
            UIWindowBase window = allWindows[removedKey[i]];
            window.DestroyWindow();

            allWindows.Remove(removedKey[i]);
        }
    }
コード例 #15
0
 public void CloseUI(UIWindowBase ui, bool isPlayAnim = true)
 {
     if (ui != null && m_uiList.Contains(ui))
     {
         m_uiList.Remove(ui);
         UIManager.CloseUIWindow(ui);
     }
     else
     {
         Debug.LogError("UI window no open from status :" + ui);
     }
 }
コード例 #16
0
    public void CloseWindow(UISettings.UIWindowID id, bool needTransform = true, System.Action onComplate = null)
    {
        SetWindowState(id, false);
        UIWindowBase window;

        allWindows.TryGetValue(id, out window);
        if (window != null)
        {
            if (showingWindows.ContainsKey(id))
            {
                showingWindows.Remove(id);
            }

            popupCollider.GetComponent <FadeIn>().to = 0;
            window.HideWindow(() =>
            {
                UIWindowData windowdata = window.windowData;
                if (windowdata.type == UISettings.UIWindowType.Fixed)
                {
                }
                else if (windowdata.type == UISettings.UIWindowType.PopUp)
                {
                    curPopUpWindow = null;
                    popupCollider.SetActive(false);
                    for (int i = PopUpRoot.childCount - 1; i >= 0; i--)
                    {
                        Transform tf = PopUpRoot.GetChild(i);
                        if (tf.gameObject.activeSelf)
                        {
                            UIWindowBase wd = tf.GetComponent <UIWindowBase>();
                            if (wd != null)
                            {
                                popupCollider.SetActive(true);
                                curPopUpWindow = wd;
                                popupCollider.transform.SetSiblingIndex(Mathf.Max(0, i - 1));

                                break;
                            }
                        }
                    }
                }
                else if (windowdata.type == UISettings.UIWindowType.Normal)
                {
                    hideNavigationWindow(window);
                }
                if (onComplate != null)
                {
                    onComplate();
                }
            }, needTransform);
        }
    }
コード例 #17
0
    public void SetLayer(UIWindowBase ui, string cameraKey = null)
    {
        UICameraData data = GetUICameraDataByKey(cameraKey);

        if (cameraKey == null)
        {
            data = GetUICameraDataByKey(ui.cameraKey);
        }
        else
        {
            data = GetUICameraDataByKey(cameraKey);
        }

        RectTransform rt = ui.GetComponent <RectTransform>();

        switch (ui.m_UIType)
        {
        case UIType.GameUI: ui.transform.SetParent(data.m_GameUILayerParent); break;

        case UIType.Fixed: ui.transform.SetParent(data.m_FixedLayerParent); break;

        case UIType.Normal:
            ui.transform.SetParent(data.m_NormalLayerParent);
            break;

        case UIType.TopBar: ui.transform.SetParent(data.m_TopbarLayerParent); break;

        case UIType.Upper: ui.transform.SetParent(data.m_UpperParent); break;

        case UIType.PopUp: ui.transform.SetParent(data.m_PopUpLayerParent); break;
        }

        rt.localScale = Vector3.one;
        rt.sizeDelta  = Vector2.zero;

        if (ui.m_UIType != UIType.GameUI)
        {
            rt.anchorMin = Vector2.zero;
            rt.anchorMax = Vector3.one;

            rt.sizeDelta = Vector2.zero;
            rt.transform.localPosition = new Vector3(0, 0, ui.m_PosZ);
            rt.anchoredPosition3D      = new Vector3(0, 0, ui.m_PosZ);
            rt.SetAsLastSibling();
        }
        else
        {
            Vector3 lp = rt.transform.localPosition;
            lp.z = 0;
            rt.transform.localPosition = lp;
        }
    }
コード例 #18
0
    private void CreateUIPrefab(string prefabName)
    {
        Type t = ReflectionUtils.GetTypeByTypeFullName(prefabName);

        if (t == null)
        {
            return;
        }

        GameObject winObj = new GameObject(prefabName);

        winObj.AddComponent <Canvas>();
        winObj.AddComponent <GraphicRaycaster>();
        UIWindowBase winBase = (UIWindowBase)winObj.AddComponent(t);

        winBase.type = type;
        winBase.mode = mode;

        UIRoot.SetUIParentByUIType(winObj, type);
        SetRectTransform(winObj);

        GameObject backGroundRoot = new GameObject("BackGroundRoot");

        backGroundRoot.transform.SetParent(winObj.transform);
        SetRectTransform(backGroundRoot);
        winBase.backGroundRoot = backGroundRoot;

        GameObject root = new GameObject("Root");

        root.transform.SetParent(winObj.transform);
        SetRectTransform(root);
        winBase.root         = root;
        winObj.layer         = LayerMask.NameToLayer("UI");
        backGroundRoot.layer = LayerMask.NameToLayer("UI");
        root.layer           = LayerMask.NameToLayer("UI");

        string p = SaveUIPrefabPathDir + prefabName + "/";

        if (!Directory.Exists(p))
        {
            Directory.CreateDirectory(p);
        }
        PrefabUtility.CreatePrefab(p + prefabName + ".prefab", winObj, ReplacePrefabOptions.ConnectToPrefab);
        AssetDatabase.Refresh();

        progress          = 1;
        isCtreatingPrefab = false;
        isCreating        = false;
        EditorUtility.ClearProgressBar();
        newUIName = "";
        UIName    = "";
    }
コード例 #19
0
    public void OnUIClose(UIWindowBase ui)
    {
        switch (ui.m_UIType)
        {
        case UIType.Fixed: m_fixedStack.Remove(ui); break;

        case UIType.Normal: m_normalStack.Remove(ui); break;

        case UIType.PopUp: m_popupStack.Remove(ui); break;

        case UIType.TopBar: m_topBarStack.Remove(ui); break;
        }
    }
コード例 #20
0
    public static void CloseUIWindow(string UIname, bool isPlayAnim = true, UICallBack callback = null, params object[] objs)
    {
        UIWindowBase ui = GetUI(UIname);

        if (ui == null)
        {
            Debug.LogError("CloseUIWindow Error UI ->" + UIname + "<-  not Exist!");
        }
        else
        {
            CloseUIWindow(GetUI(UIname), isPlayAnim, callback, objs);
        }
    }
コード例 #21
0
        public void Call(UIWindowBase param0, object[] param1)
        {
            func.BeginPCall();
            func.Push(param0);

            for (int i = 0; i < param1.Length; i++)
            {
                func.Push(param1[i]);
            }

            func.PCall();
            func.EndPCall();
        }
コード例 #22
0
        static public LuaUIWindow GetWindow(string uiName)
        {
            UIWindowBase window = UIManager.Instance.GetWindow(uiName);

            if (window is LuaUIWindow)
            {
                return(window as LuaUIWindow);
            }
            else
            {
                return(null);
            }
        }
コード例 #23
0
        protected void ClearGuideLogic()
        {
            if (m_currentOperationWindow != null)
            {
                ClearGuideBehaveByUI(m_currentOperationWindow);
                m_currentOperationWindow = null;
            }

            //取消自定义事件监听
            RemoveCustomEventListener(GetCustomEvent(m_currentGuideData));

            ClearGuideBehave();
        }
コード例 #24
0
    public UIWindowBase GetOrLoadUiWindow(UIWindowInfo winInfo)
    {
        UIWindowBase win;

        if (winLoadedDict.TryGetValue((int)winInfo.windowEnum, out win))
        {
            return(win);
        }

        GameObject obj = Resources.Load(winInfo.PrefabFullPath) as GameObject;

        if (obj = null)
        {
            Debug.LogError("加载win出错");
            return(null);
        }

        GameObject   ui       = obj;
        UIWindowBase uiWindow = ui.GetComponent <UIWindowBase>();

        if (uiWindow == null)
        {
            Debug.LogError("perfab doesn't have window Script");
            return(null);
        }

        winLoadedDict[(int)winInfo.windowEnum] = uiWindow;

        if (winInfo.windowType == UIWindowType.oNormal)
        {
            uiWindow.transform.SetParent(normalWindowRoot);
        }
        else
        {
            uiWindow.transform.SetParent(popupWindowRoot);
        }


        var cvs = ui.GetComponent <Canvas>();

        if (cvs != null && !cvs.overrideSorting)
        {
            cvs.overrideSorting = true;
            cvs.sortingOrder    = 3;
        }

        //描点处理
        //TODO..

        return(uiWindow);
    }
コード例 #25
0
 public bool IsUIOpen <T>() where T : UIWindowBase
 {
     for (int i = 0; i < m_uiList.Count; i++)
     {
         UIWindowBase tempWin = m_uiList[i];
         if (tempWin.GetType() == typeof(T) &&
             (tempWin.windowStatus == UIWindowBase.WindowStatus.Open ||
              tempWin.windowStatus == UIWindowBase.WindowStatus.OpenAnim))
         {
             return(true);
         }
     }
     return(false);
 }
コード例 #26
0
 static int OnRefresh(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         UIWindowBase obj = (UIWindowBase)ToLua.CheckObject(L, 1, typeof(UIWindowBase));
         obj.OnRefresh();
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
コード例 #27
0
 static int RemoveAllListener(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         UIWindowBase obj = (UIWindowBase)ToLua.CheckObject(L, 1, typeof(UIWindowBase));
         obj.RemoveAllListener();
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
コード例 #28
0
    public static UIWindowBase ShowUI(UIWindowBase ui)
    {
        try
        {
            ui.Show();
            ui.OnShow();
        }
        catch (Exception e)
        {
            Debug.LogError(ui.UIName + " OnShow Exception: " + e.ToString());
        }

        return(ui);
    }
コード例 #29
0
ファイル: UIManager.cs プロジェクト: U3DC/MyUnityFrameWork
    static void CloseUIWindowCallBack(UIWindowBase UI, params object[] objs)
    {
        UISystemEvent.Dispatch(UI, UIEvent.OnClose);  //派发OnClose事件
        try
        {
            UI.OnClose();
        }
        catch (Exception e)
        {
            Debug.LogError(UI.UIName + " OnClose Exception: " + e.ToString());
        }

        AddHideUI(UI);
    }
コード例 #30
0
 static int DestroyUI(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         UIWindowBase arg0 = (UIWindowBase)ToLua.CheckUnityObject(L, 1, typeof(UIWindowBase));
         UIManager.DestroyUI(arg0);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
コード例 #31
0
    public static void Dispatch(UIWindowBase l_UI, UIEvent l_UIEvent,params object[] l_objs)
    {
        if (l_UI == null)
        {
            Debug.LogError("Dispatch l_UI is null!");

            return;
        }

        if (s_allUIEvents.ContainsKey(l_UIEvent))
        {
            //遍历委托链表
            foreach (UICallBack callBack in s_allUIEvents[l_UIEvent].GetInvocationList())
            {
                try
                {
                    callBack(l_UI, l_objs);
                }
                catch (Exception e)
                {
                    Debug.LogError("UISystemEvent Dispatch error:" + e.ToString());
                }
            }
        }

        if (s_singleUIEvents.ContainsKey(l_UI.name))
        {
            if (s_singleUIEvents[l_UI.name].ContainsKey(l_UIEvent))
            {
                //遍历委托链表
                foreach (UICallBack callBack in s_singleUIEvents[l_UI.name][l_UIEvent].GetInvocationList())
                {
                    try
                    {
                        callBack(l_UI, l_objs);
                    }
                    catch (Exception e)
                    {
                        Debug.LogError("UISystemEvent Dispatch error:" + e.ToString());
                    }
                }
            }
        }
    }
コード例 #32
0
 public static double CallOnExitAnim(UIWindowBase UI)
 {
     return (double)LuaManager.LuaState.GetFunction("LuaUIManager.UIOnExitAnim").Call(UI)[0];
 }
コード例 #33
0
 public static void CallOnCompleteExitAnim(UIWindowBase UI)
 {
     LuaManager.LuaState.GetFunction("LuaUIManager.UIOnCompleteExitAnim").Call(UI);
 }
コード例 #34
0
 public static void CallOnUIDestroy(UIWindowBase UI)
 {
     LuaManager.LuaState.GetFunction("LuaUIManager.UIOnDestroy").Call(UI);
 }
コード例 #35
0
 public static void CallOnClose(UIWindowBase UI)
 {
     LuaManager.LuaState.GetFunction("LuaUIManager.UIOnClose").Call(UI);
 }
コード例 #36
0
 public static void CallOnUIInit(UIWindowBase UI)
 {
     LuaManager.LuaState.GetFunction("LuaUIManager.UIOnInit").Call(UI);
 }