コード例 #1
0
ファイル: WindowStack.cs プロジェクト: potsh/RimWorld
 public void ImmediateWindow(int ID, Rect rect, WindowLayer layer, Action doWindowFunc, bool doBackground = true, bool absorbInputAroundWindow = false, float shadowAlpha = 1f)
 {
     if (Event.current.type == EventType.Repaint)
     {
         if (ID == 0)
         {
             Log.Warning("Used 0 as immediate window ID.");
         }
         else
         {
             ID = -Math.Abs(ID);
             bool flag = false;
             for (int i = 0; i < windows.Count; i++)
             {
                 if (windows[i].ID == ID)
                 {
                     ImmediateWindow immediateWindow = (ImmediateWindow)windows[i];
                     immediateWindow.windowRect              = rect;
                     immediateWindow.doWindowFunc            = doWindowFunc;
                     immediateWindow.layer                   = layer;
                     immediateWindow.doWindowBackground      = doBackground;
                     immediateWindow.absorbInputAroundWindow = absorbInputAroundWindow;
                     immediateWindow.shadowAlpha             = shadowAlpha;
                     flag = true;
                     break;
                 }
             }
             if (!flag)
             {
                 AddNewImmediateWindow(ID, rect, layer, doWindowFunc, doBackground, absorbInputAroundWindow, shadowAlpha);
             }
             immediateWindowsRequests.Add(ID);
         }
     }
 }
コード例 #2
0
        public IEnumerator _04_WindowLayerIsPresent()
        {
            WindowLayer windowLayer = uiFrame.GetComponentInChildren <WindowLayer>();

            Assert.NotNull(windowLayer);
            yield return(null);
        }
コード例 #3
0
 private void AddToActivedWindowQueue(WindowLayer layer, WindowBase windowHandler)
 {
     if (!m_ActivedWindowQueue.ContainsKey(layer))
     {
         m_ActivedWindowQueue.Add(layer, new List <WindowBase>());
     }
     m_ActivedWindowQueue[layer].Add(windowHandler);
 }
コード例 #4
0
 private void RemoveFromActivedWindowQueue(WindowLayer layer, WindowBase windowHandler)
 {
     if (!m_ActivedWindowQueue.ContainsKey(layer))
     {
         return;
     }
     m_ActivedWindowQueue[layer].Remove(windowHandler);
 }
コード例 #5
0
 public WindowIndexStruct(int id, string path, WindowLayer layer, Type type, bool isBuildWindow = true)
 {
     m_ID               = id;
     m_strPath          = path;
     m_Layer            = layer;
     m_Type             = type;
     m_bIsBuildInWindow = isBuildWindow;
 }
コード例 #6
0
    static int IntToEnum(IntPtr L)
    {
        int         arg0 = (int)LuaDLL.lua_tonumber(L, 1);
        WindowLayer o    = (WindowLayer)arg0;

        ToLua.Push(L, o);
        return(1);
    }
コード例 #7
0
ファイル: UIWindowManager.cs プロジェクト: xldeng1203/project
    public void PushWindow(string assetName, string bundleName, Action <UIWindow> onComplete)
    {
        AssetManager.Instance.LoadAsset <UIWindow>(assetName, bundleName, delegate(string error, UIWindow window)
        {
            if (!string.IsNullOrEmpty(error))
            {
                Debug.LogError(string.Format("load window at {0}:{1} failed!!!", assetName, bundleName));
                return;
            }

            UIWindow newWindow = GameObject.Instantiate <GameObject>(window.gameObject).GetComponent <UIWindow>();

            newWindow.transform.localScale    = Vector3.one;
            newWindow.transform.localRotation = Quaternion.identity;
            newWindow.transform.localPosition = Vector3.zero;

            UIWindowStack stack    = null;
            newWindow.DynamicLayer = newWindow.OriginalLayer;

            stacks.TryGetValue(newWindow.OriginalLayer, out stack);

            if (newWindow.OriginalLayer != WindowLayer.UIMain && newWindow.OriginalLayer != WindowLayer.UIMainView)
            {
                WindowLayer highestLayer = GetHighestLayer();
                if ((int)highestLayer > (int)newWindow.OriginalLayer)
                {
                    newWindow.DynamicLayer = highestLayer;
                    stacks.TryGetValue(highestLayer, out stack);
                }
            }

            Assert.IsTrue(stack != null);
            stack.PushWindow(newWindow);

            UIWindow pendingWindow = null;

            if (openWindows.Count > 0)
            {
                pendingWindow = openWindows.Peek();
            }

            openWindows.Push(newWindow);

            if (pendingWindow != null)
            {
                pendingWindow.OnPause();
            }

            if (onComplete != null)
            {
                onComplete(newWindow);
            }

            newWindow.OnShow();
        });
    }
コード例 #8
0
ファイル: Depth.cs プロジェクト: OkashiKami/Odyssey
 public override int GetHashCode()
 {
     unchecked
     {
         int result = WindowLayer.GetHashCode();
         result = (result * 397) ^ ComponentLayer.GetHashCode();
         result = (result * 397) ^ ZOrder.GetHashCode();
         return(result);
     }
 }
コード例 #9
0
    public void RegisterWindow(int id, string path, WindowLayer layer, Type type)
    {
        if (m_WindowIndexStore.ContainsKey(id))
        {
            return;
        }
        WindowIndexStruct element = new WindowIndexStruct(id, path, layer, type);

        m_WindowIndexStore.Add(id, element);
    }
コード例 #10
0
        public override void LessonOnGUI()
        {
            Rect  mainRect = this.MainRect;
            float alpha    = 1f;

            if (this.doFadeIn)
            {
                alpha = Mathf.Clamp01((float)(base.AgeSeconds / 0.40000000596046448));
            }
            if (this.Expiring)
            {
                float num = this.expiryTime - Time.timeSinceLevelLoad;
                if (num < 1.1000000238418579)
                {
                    alpha = (float)(num / 1.1000000238418579);
                }
            }
            WindowStack windowStack  = Find.WindowStack;
            int         iD           = 134706;
            Rect        rect         = mainRect;
            WindowLayer layer        = WindowLayer.Super;
            Action      doWindowFunc = delegate
            {
                Rect rect2 = mainRect.AtZero();
                Text.Font = GameFont.Small;
                if (!this.Expiring)
                {
                    this.def.HighlightAllTags();
                }
                if (this.doFadeIn || this.Expiring)
                {
                    GUI.color = new Color(1f, 1f, 1f, alpha);
                }
                Widgets.DrawWindowBackgroundTutor(rect2);
                Rect rect3 = rect2.ContractedBy(10f);
                rect3.width = 432f;
                Widgets.Label(rect3, this.def.HelpTextAdjusted);
                Rect      butRect = new Rect((float)(rect2.xMax - 32.0 - 8.0), (float)(rect2.y + 8.0), 32f, 32f);
                Texture2D tex     = (!this.Expiring) ? TexButton.CloseXBig : Widgets.CheckboxOnTex;
                if (Widgets.ButtonImage(butRect, tex, new Color(0.95f, 0.95f, 0.95f), new Color(0.8352941f, 0.6666667f, 0.274509817f)))
                {
                    SoundDefOf.Click.PlayOneShotOnCamera(null);
                    this.CloseButtonClicked();
                }
                if (Time.timeSinceLevelLoad > this.expiryTime)
                {
                    this.CloseButtonClicked();
                }
                GUI.color = Color.white;
            };
            bool  doBackground = false;
            float shadowAlpha  = alpha;

            windowStack.ImmediateWindow(iD, rect, layer, doWindowFunc, doBackground, false, shadowAlpha);
        }
コード例 #11
0
 public void SetWindowLayer(string window, WindowLayer layer)
 {
     if (m_PanelLayerMap.ContainsKey(window))
     {
         m_PanelLayerMap [window] = layer;
     }
     else
     {
         m_PanelLayerMap.Add(window, layer);
     }
 }
コード例 #12
0
    private int ResetDeepth(WindowLayer layer)
    {
        int lastWindowDeepth = m_LayerIndexStore[layer].m_iMin;

        for (int i = 0; i < m_ActivedWindowQueue[layer].Count; ++i)
        {
            m_ActivedWindowQueue[layer][i].ResetDeepth(lastWindowDeepth + 1);
            lastWindowDeepth = m_ActivedWindowQueue[layer][i].GetMaxDeepthValue();
        }
        m_LayerIndexStore[layer].m_iCurrent = lastWindowDeepth + 1;
        return(m_LayerIndexStore[layer].m_iCurrent);
    }
コード例 #13
0
ファイル: UIManager.cs プロジェクト: zjljxsc/cshotfix
        //private static WindowBase WindowCreate(string uifile, WindowBase parent)
        //{
        //    WindowBase win = UICreator.GetUIInstance(uifile);
        //    if (win != null)
        //    {
        //        StringBuilder sb = Tool.StringBuilder.AppendFormat("ui/{0}", uifile.ToLower());
        //        string abname = sb.ToString();
        //        sb.Clear();
        //        win.m_UIName = uifile;
        //        win.m_ABId = ResourceManager.LoadPrefab(typeof(GameObject), abname, uifile, (abobject)=>
        //        {
        //            #region 异步加载UI资源回调
        //            win.m_WinObj = (GameObject)GameObject.Instantiate(abobject.m_UObjectList[0]);

        //            GameObject AttachObject = GetLayer(win.m_Layer);

        //            if (AttachObject == null)
        //            {
        //                UnityEngine.Debug.LogWarning("挂节点没有找到");
        //                return;
        //            }
        //            //先将大小还原到他的父对象的局部坐标
        //            Vector3 parentScale = AttachObject.transform.localScale;
        //            Vector3 now = win.m_WinTransform.localScale;
        //            Vector3 childScale = new Vector3(now.x * parentScale.x, now.y * parentScale.y, now.z * parentScale.z);
        //            win.m_WinTransform.localScale = childScale;


        //            //挂接到对应的位置
        //            RectTransform rect = win.m_WinObj.GetComponent(typeof(RectTransform)) as RectTransform;
        //            if (rect != null)
        //            {
        //                Vector3 pos = rect.anchoredPosition3D;

        //                Quaternion rotation = rect.localRotation;

        //                Vector3 scale = rect.localScale;

        //                Vector2 offsetMax = rect.offsetMax;

        //                Vector2 offsetMin = rect.offsetMin;

        //                win.m_WinTransform.SetParent(AttachObject.transform);
        //                rect.anchoredPosition3D = pos;
        //                rect.localRotation = rotation;
        //                rect.localScale = scale;


        //                rect.offsetMax = offsetMax;
        //                rect.offsetMin = offsetMin;

        //            }
        //            win.m_WindowPos = win.m_WinTransform.position;
        //            win.OpenWindow();
        //            //设置该layer下面层级
        //            SortLayerWindows(win.m_Layer);
        //            win.m_WindowPos = win.m_WinTransform.position;


        //            #endregion
        //        });
        //        if(parent!= null)
        //        {
        //            parent.AddChild(win);
        //        }
        //        m_OpenedList.Add(win);
        //        //添加逻辑窗口和层的对应关系
        //        List<WindowBase> winList = null;
        //        if (m_LayerWindows.TryGetValue((int)win.m_Layer, out winList))
        //        {
        //            winList.Add(win);
        //        }
        //        else
        //        {
        //            winList = new List<WindowBase>();
        //            winList.Add(win);
        //            m_LayerWindows.Add((int)win.m_Layer, winList);
        //        }
        //        return win;
        //    }
        //    else
        //    {
        //        UnityEngine.Debug.LogError("打开的窗口不存在," + uifile);
        //    }

        //    return null;
        //}
        private static List <WindowBase> GetWindowsByLayer(WindowLayer layer)
        {
            int layerInt = (int)layer;

            if (m_LayerWindows.ContainsKey(layerInt))
            {
                return(m_LayerWindows[layerInt]);
            }
            else
            {
                return(null);
            }
        }
コード例 #14
0
ファイル: UIWindowManager.cs プロジェクト: xldeng1203/project
    WindowLayer GetHighestLayer()
    {
        WindowLayer highestLayer = WindowLayer.None;

        foreach (var window in openWindows)
        {
            if (window.DynamicLayer > highestLayer)
            {
                highestLayer = window.DynamicLayer;
            }
        }

        return(highestLayer);
    }
コード例 #15
0
    private int GetCurrentWindowDeepth(WindowLayer layer)
    {
        int currentLayerDeepth = ++m_LayerIndexStore[layer].m_iCurrent;

        if (currentLayerDeepth > m_LayerIndexStore[layer].m_iMax)
        {
            currentLayerDeepth = ResetDeepth(layer);
        }
        if (currentLayerDeepth > m_LayerIndexStore[layer].m_iMax)
        {
            Debuger.LogError("panel deepth out of range");
        }
        return(currentLayerDeepth);
    }
コード例 #16
0
    static int LoadUICallBack(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 9 && TypeChecker.CheckTypes(L, 1, typeof(UIManager), typeof(AssetLoader), typeof(WindowLayer), typeof(UnityEngine.Object), typeof(UIExtendType), typeof(UIOpenType), typeof(bool), typeof(bool), typeof(int)))
            {
                UIManager          obj  = (UIManager)ToLua.ToObject(L, 1);
                AssetLoader        arg0 = (AssetLoader)ToLua.ToObject(L, 2);
                WindowLayer        arg1 = (WindowLayer)ToLua.ToObject(L, 3);
                UnityEngine.Object arg2 = (UnityEngine.Object)ToLua.ToObject(L, 4);
                UIExtendType       arg3 = (UIExtendType)ToLua.ToObject(L, 5);
                UIOpenType         arg4 = (UIOpenType)ToLua.ToObject(L, 6);
                bool arg5 = LuaDLL.lua_toboolean(L, 7);
                bool arg6 = LuaDLL.lua_toboolean(L, 8);
                int  arg7 = (int)LuaDLL.lua_tonumber(L, 9);
                UnityEngine.GameObject o = obj.LoadUICallBack(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7);
                ToLua.Push(L, o);
                return(1);
            }
            else if (count == 12 && TypeChecker.CheckTypes(L, 1, typeof(UIManager), typeof(UnityEngine.UI.CanvasScaler.ScreenMatchMode), typeof(WindowLayer), typeof(float), typeof(AssetLoader), typeof(UnityEngine.Object), typeof(UIExtendType), typeof(UIOpenType), typeof(UILayerType), typeof(bool), typeof(bool), typeof(int)))
            {
                UIManager obj = (UIManager)ToLua.ToObject(L, 1);
                UnityEngine.UI.CanvasScaler.ScreenMatchMode arg0 = (UnityEngine.UI.CanvasScaler.ScreenMatchMode)ToLua.ToObject(L, 2);
                WindowLayer        arg1 = (WindowLayer)ToLua.ToObject(L, 3);
                float              arg2 = (float)LuaDLL.lua_tonumber(L, 4);
                AssetLoader        arg3 = (AssetLoader)ToLua.ToObject(L, 5);
                UnityEngine.Object arg4 = (UnityEngine.Object)ToLua.ToObject(L, 6);
                UIExtendType       arg5 = (UIExtendType)ToLua.ToObject(L, 7);
                UIOpenType         arg6 = (UIOpenType)ToLua.ToObject(L, 8);
                UILayerType        arg7 = (UILayerType)ToLua.ToObject(L, 9);
                bool arg8  = LuaDLL.lua_toboolean(L, 10);
                bool arg9  = LuaDLL.lua_toboolean(L, 11);
                int  arg10 = (int)LuaDLL.lua_tonumber(L, 12);
                UnityEngine.GameObject o = obj.LoadUICallBack(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10);
                ToLua.Push(L, o);
                return(1);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: UIManager.LoadUICallBack"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
コード例 #17
0
ファイル: UIManager.cs プロジェクト: zjljxsc/cshotfix
        private static void SetWindowLayerCanvas(GameObject obj, WindowLayer layer)
        {
            int    idx         = (int)layer;
            Canvas childCanvas = obj.AddComponent(typeof(Canvas)) as Canvas;

            childCanvas.overrideSorting          = true;
            childCanvas.sortingLayerName         = "Default";
            childCanvas.sortingOrder             = idx * 1000;
            childCanvas.additionalShaderChannels = AdditionalCanvasShaderChannels.TexCoord1 | AdditionalCanvasShaderChannels.Normal | AdditionalCanvasShaderChannels.Tangent;

            m_LayerRenderOrder.Add(idx, childCanvas.sortingOrder);

            childCanvas.gameObject.transform.localPosition = new Vector3(10000, 10000, 12000 - idx * 2000);
            obj.AddComponent(typeof(GraphicRaycaster));
        }
コード例 #18
0
 public MaterialFilterWindow(ThingFilter __filter, float __top, float __left, WindowLayer __layer)
 {
     this.layer = __layer;
     this.preventCameraMotion   = false;
     this.soundAppear           = SoundDefOf.TabOpen;
     this.soundClose            = SoundDefOf.TabClose;
     this.doCloseX              = false;
     this.closeOnClickedOutside = true;
     this.def        = MainButtonDefOf.Menu; // new in 1.3 i guess
     this.resizeable = false;
     this.draggable  = false;
     this.left       = __left;
     this.top        = __top;
     this.filter     = __filter;
     this.sdefs      = DefDatabase <SpecialThingFilterDef> .AllDefsListForReading.FindAll(x => x.defName.StartsWith("MaterialFilter")).OrderBy <SpecialThingFilterDef, string>(sdefs => sdefs.label);
 }
コード例 #19
0
 static int GetPanelLayer(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         UIManager   obj  = (UIManager)ToLua.CheckObject(L, 1, typeof(UIManager));
         WindowLayer arg0 = (WindowLayer)ToLua.CheckObject(L, 2, typeof(WindowLayer));
         System.Collections.Generic.List <UIController> o = obj.GetPanelLayer(arg0);
         ToLua.PushObject(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
コード例 #20
0
 public void HandleCameraMovement()
 {
     if (WindowLayer.GetKey(ctx, 'I'))
     {
         camera2D.position += vec2.UnitY * CAMERA_SPEED * deltaTime;
     }
     if (WindowLayer.GetKey(ctx, 'K'))
     {
         camera2D.position += -vec2.UnitY * CAMERA_SPEED * deltaTime;
     }
     if (WindowLayer.GetKey(ctx, 'J'))
     {
         camera2D.position += -vec2.UnitX * CAMERA_SPEED * deltaTime;
     }
     if (WindowLayer.GetKey(ctx, 'L'))
     {
         camera2D.position += vec2.UnitX * CAMERA_SPEED * deltaTime;
     }
 }
コード例 #21
0
 static int AddDlg(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 7);
         UIManager obj = (UIManager)ToLua.CheckObject(L, 1, typeof(UIManager));
         UnityEngine.GameObject arg0 = (UnityEngine.GameObject)ToLua.CheckUnityObject(L, 2, typeof(UnityEngine.GameObject));
         WindowLayer            arg1 = (WindowLayer)ToLua.CheckObject(L, 3, typeof(WindowLayer));
         UIOpenType             arg2 = (UIOpenType)ToLua.CheckObject(L, 4, typeof(UIOpenType));
         bool    arg3 = LuaDLL.luaL_checkboolean(L, 5);
         bool    arg4 = LuaDLL.luaL_checkboolean(L, 6);
         int     arg5 = (int)LuaDLL.luaL_checknumber(L, 7);
         UILayer o    = obj.AddDlg(arg0, arg1, arg2, arg3, arg4, arg5);
         ToLua.Push(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
コード例 #22
0
        private void AddNewImmediateWindow(int ID, Rect rect, WindowLayer layer, Action doWindowFunc, bool doBackground, bool absorbInputAroundWindow, float shadowAlpha)
        {
            if (ID >= 0)
            {
                Log.Error("Invalid immediate window ID.");
                return;
            }
            ImmediateWindow immediateWindow = new ImmediateWindow();

            immediateWindow.ID                      = ID;
            immediateWindow.layer                   = layer;
            immediateWindow.doWindowFunc            = doWindowFunc;
            immediateWindow.doWindowBackground      = doBackground;
            immediateWindow.absorbInputAroundWindow = absorbInputAroundWindow;
            immediateWindow.shadowAlpha             = shadowAlpha;
            immediateWindow.PreOpen();
            immediateWindow.windowRect = rect;
            InsertAtCorrectPositionInList(immediateWindow);
            FocusAfterInsertIfShould(immediateWindow);
            updateInternalWindowsOrderLater = true;
            immediateWindow.PostOpen();
        }
コード例 #23
0
ファイル: UIManager.cs プロジェクト: zjljxsc/cshotfix
        private static string GetWindowLayerName(WindowLayer layer)
        {
            string name = "";

            if (layer == WindowLayer.Effect)
            {
                name = "Effect";
            }
            else if (layer == WindowLayer.Guide)
            {
                name = "Guide";
            }
            else if (layer == WindowLayer.Hold)
            {
                name = "Hold";
            }
            else if (layer == WindowLayer.HUD)
            {
                name = "HUD";
            }
            else if (layer == WindowLayer.Loading)
            {
                name = "Loading";
            }
            else if (layer == WindowLayer.Notice)
            {
                name = "Notice";
            }
            else if (layer == WindowLayer.Popup)
            {
                name = "Popup";
            }
            else
            {
                name = "NoneLayer";
            }
            return(name);
        }
コード例 #24
0
        // --

        public void HandleQuadMovement()
        {
            if (WindowLayer.GetKeyDown(ctx, 'W') && Math.Abs(quad.body.GetVelocity().y) <= 0.01f)
            {
                quad.body.ApplyImpulse(IMPULSE_POWER);
            }
            if (WindowLayer.GetKey(ctx, 'A'))
            {
                quad.Move(-vec2.UnitX * deltaTime);
            }
            if (WindowLayer.GetKey(ctx, 'D'))
            {
                quad.Move(vec2.UnitX * deltaTime);
            }
            if (WindowLayer.GetKey(ctx, 'Q'))
            {
                quad.Rotate(deltaTime * (float)Math.PI);
            }
            if (WindowLayer.GetKey(ctx, 'E'))
            {
                quad.Rotate(-deltaTime * (float)Math.PI);
            }
        }
コード例 #25
0
 public TextureInfo(WindowLayer layer, RenderTexture texture)
 {
     Layer   = layer;
     Texture = texture;
 }
コード例 #26
0
    public bool ShowWindow(string window, object data = null)
    {
        int    index = m_Stack.FindIndex(x => x.name == window);
        UIView view  = null;
        bool   ret   = false;

        if (index >= 0)
        {
            view = m_Stack[index];
            view.rt.SetAsLastSibling();
            if (view.rt.gameObject.activeInHierarchy == false)
            {
                view.rt.gameObject.SetActive(true);
            }
            m_Stack.RemoveAt(index);
        }
        else
        {
            Object     obj   = ResourceManager.Instance.LoadAsset("UI", window);
            GameObject panel = Instantiate(obj as GameObject);
            panel.name = window;
            //LuaBehaviour lua = panel.GetComponent<LuaBehaviour>();
            //if (lua == null) lua = panel.AddComponent<LuaBehaviour>();

            RectTransform rt = panel.GetComponent <RectTransform>();
            rt.SetParent(Root);

            rt.sizeDelta     = new Vector2(0, 0);
            rt.localScale    = Vector3.one;
            rt.localPosition = new Vector3(0, 0, 0);

            view = new UIView {
                name = window, rt = rt
            };
            //view = new UIView{name=window,rt=rt, script=lua};

            ret = true;
        }

        // set layer
        WindowLayer layer = WindowLayer.Normal;

        if (m_PanelLayerMap.ContainsKey(window))
        {
            layer = m_PanelLayerMap[window];
        }
        int idx = 0;

        if (m_Stack.Count > 0)
        {
            for (; idx < m_Stack.Count; idx++)
            {
                WindowLayer layer2 = WindowLayer.Normal;
                if (m_PanelLayerMap.ContainsKey(m_Stack[idx].name))
                {
                    layer2 = m_PanelLayerMap[m_Stack[idx].name];
                }
                if (layer2 > layer)
                {
                    break;
                }
            }
            if (idx == m_Stack.Count)
            {
                view.rt.SetAsLastSibling();
                m_Stack.Add(view);
            }
            else
            {
                int siblingIndex = m_Stack[idx].rt.GetSiblingIndex();
                for (int i = m_Stack.Count - 1; i >= idx; i--)                   // move back
                {
                    m_Stack[i].rt.SetSiblingIndex(m_Stack[i].rt.GetSiblingIndex() + 1);
                }
                view.rt.SetSiblingIndex(siblingIndex);

                m_Stack.Insert(idx, view);
            }
        }
        else
        {
            view.rt.SetSiblingIndex(Root.childCount - 1);
            m_Stack.Add(view);
        }

        // set mode
        WindowMode mode = WindowMode.None;

        if (m_PanelModeMap.ContainsKey(window))
        {
            mode = m_PanelModeMap[window];
        }
        if (mode == WindowMode.HideOther)
        {
            for (int i = idx - 1; i >= 0; i--)
            {
                view = m_Stack[i];
                WindowMode mode2 = WindowMode.None;
                if (m_PanelModeMap.ContainsKey(view.name))
                {
                    mode2 = m_PanelModeMap [view.name];
                }

                if (mode2 == WindowMode.HideOther)
                {
                    // 隐藏后面的window
                    view.rt.gameObject.SetActive(false);
                    break;
                }
            }
        }

        return(ret);
    }
コード例 #27
0
 public SpreadApplication(WindowLayer.Options opts, ResourceManager res)
 {
     ctx = WindowLayer.CreateWindowContext(opts);
     SpreadApplication.res = res;
     UILayer.InitializeUI(ctx, "#version 440 core", "res/Roboto-Regular.ttf");
 }
コード例 #28
0
ファイル: UIManager.cs プロジェクト: zjljxsc/cshotfix
        public static void CreateUIStruct()
        {
            Debug.Log("Create UI Struct In Dll");
            m_GlobalUI = new GameObject("GlobalUI");
            GameObject.DontDestroyOnLoad(m_GlobalUI);


            //相机
            GameObject camgo = new GameObject("UICamera");
            Transform  cam   = camgo.transform;

            m_UICamera                     = cam.gameObject.AddComponent(typeof(Camera)) as Camera;
            m_UICamera.allowHDR            = false;
            m_UICamera.orthographicSize    = 1;
            m_UICamera.orthographic        = true;
            m_UICamera.useOcclusionCulling = true;
            m_UICamera.nearClipPlane       = 1.0f;
            m_UICamera.farClipPlane        = 100;
            m_UICamera.clearFlags          = CameraClearFlags.Depth;
            m_UICamera.cullingMask         = LayerMask.GetMask("UI", "UI3D", "UIVFX");
            m_UICamera.transform.position  = new Vector3(10000, 10000, 0);

            //画布
            m_GlobalCanvas = new GameObject("GlobalCanavs");
            m_GlobalCanvas.transform.SetParent(m_GlobalUI.transform, false);

            cam.transform.SetParent(m_GlobalCanvas.transform, false);

            m_GlobalCanvas.layer = LayerMask.NameToLayer("UI");
            Canvas canvas = m_GlobalCanvas.AddComponent(typeof(Canvas)) as Canvas;

            canvas.renderMode               = RenderMode.ScreenSpaceCamera;
            canvas.worldCamera              = m_UICamera;
            canvas.planeDistance            = 15;
            canvas.additionalShaderChannels = AdditionalCanvasShaderChannels.TexCoord1 | AdditionalCanvasShaderChannels.Normal | AdditionalCanvasShaderChannels.Tangent;

            m_CanvasRect = m_GlobalCanvas.GetComponent(typeof(RectTransform)) as RectTransform;

            //画布适配器
            m_CanvasScaler                     = m_GlobalCanvas.AddComponent(typeof(CanvasScaler)) as CanvasScaler;
            m_CanvasScaler.uiScaleMode         = CanvasScaler.ScaleMode.ScaleWithScreenSize;
            m_CanvasScaler.referenceResolution = LogicRoot.m_ScreenDesignSize;
            m_CanvasScaler.matchWidthOrHeight  = SetMatchWidthOrHeight(Screen.width, Screen.height);
            m_GlobalCanvas.AddComponent(typeof(GraphicRaycaster));


            //事件
            GameObject evtObj = new GameObject("EventSystem");

            evtObj.transform.SetParent(m_GlobalUI.transform, false);
            m_EventSystem = evtObj.AddComponent(typeof(EventSystem)) as EventSystem;
            //evtObj.AddComponent<TouchInputModule>();
            evtObj.AddComponent(typeof(StandaloneInputModule));



            //层级
            //注意:枚举的GetValues可能无法在热更新里面用
            for (int i = 0; i < (int)WindowLayer.Count; ++i)
            {
                WindowLayer layer = (WindowLayer)i;
                string      name  = GetWindowLayerName(layer);
                Transform   tr    = m_GlobalCanvas.transform.Find(name);
                if (tr == null)
                {
                    GameObject obj = new GameObject(name);
                    obj.transform.SetParent(m_GlobalCanvas.transform, false);
                    RectTransform rt = obj.AddComponent(typeof(RectTransform)) as RectTransform;
                    obj.layer = LayerMask.NameToLayer("UI");

                    rt.anchorMin = new Vector2(0, 0);
                    rt.anchorMax = new Vector2(1, 1);
                    rt.sizeDelta = new Vector2(0, 0);
                    tr           = rt;
                    SetWindowLayerCanvas(obj, layer);
                }
                m_LayerGameObjects.Add((int)layer, tr);
            }
        }
コード例 #29
0
ファイル: UIManager.cs プロジェクト: zjljxsc/cshotfix
 public static Transform GetLayer(WindowLayer layer)
 {
     return(m_LayerGameObjects[(int)layer]);
 }
コード例 #30
0
    static int CreatePanel(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 2 && TypeChecker.CheckTypes(L, 1, typeof(PanelManager), typeof(string)))
            {
                PanelManager obj  = (PanelManager)ToLua.ToObject(L, 1);
                string       arg0 = ToLua.ToString(L, 2);
                obj.CreatePanel(arg0);
                return(0);
            }
            else if (count == 3 && TypeChecker.CheckTypes(L, 1, typeof(PanelManager), typeof(string), typeof(WindowLayer)))
            {
                PanelManager obj  = (PanelManager)ToLua.ToObject(L, 1);
                string       arg0 = ToLua.ToString(L, 2);
                WindowLayer  arg1 = (WindowLayer)ToLua.ToObject(L, 3);
                obj.CreatePanel(arg0, arg1);
                return(0);
            }
            else if (count == 3 && TypeChecker.CheckTypes(L, 1, typeof(PanelManager), typeof(string), typeof(object)))
            {
                PanelManager obj  = (PanelManager)ToLua.ToObject(L, 1);
                string       arg0 = ToLua.ToString(L, 2);
                object       arg1 = ToLua.ToVarObject(L, 3);
                obj.CreatePanel(arg0, arg1);
                return(0);
            }
            else if (count == 4 && TypeChecker.CheckTypes(L, 1, typeof(PanelManager), typeof(string), typeof(UIExtendType), typeof(object)))
            {
                PanelManager obj  = (PanelManager)ToLua.ToObject(L, 1);
                string       arg0 = ToLua.ToString(L, 2);
                UIExtendType arg1 = (UIExtendType)ToLua.ToObject(L, 3);
                object       arg2 = ToLua.ToVarObject(L, 4);
                obj.CreatePanel(arg0, arg1, arg2);
                return(0);
            }
            else if (count == 5 && TypeChecker.CheckTypes(L, 1, typeof(PanelManager), typeof(string), typeof(UIExtendType), typeof(UIOpenType), typeof(object)))
            {
                PanelManager obj  = (PanelManager)ToLua.ToObject(L, 1);
                string       arg0 = ToLua.ToString(L, 2);
                UIExtendType arg1 = (UIExtendType)ToLua.ToObject(L, 3);
                UIOpenType   arg2 = (UIOpenType)ToLua.ToObject(L, 4);
                object       arg3 = ToLua.ToVarObject(L, 5);
                obj.CreatePanel(arg0, arg1, arg2, arg3);
                return(0);
            }
            else if (count == 8 && TypeChecker.CheckTypes(L, 1, typeof(PanelManager), typeof(string), typeof(WindowLayer), typeof(UIExtendType), typeof(UIOpenType), typeof(LuaInterface.LuaFunction), typeof(object), typeof(int)))
            {
                PanelManager obj  = (PanelManager)ToLua.ToObject(L, 1);
                string       arg0 = ToLua.ToString(L, 2);
                WindowLayer  arg1 = (WindowLayer)ToLua.ToObject(L, 3);
                UIExtendType arg2 = (UIExtendType)ToLua.ToObject(L, 4);
                UIOpenType   arg3 = (UIOpenType)ToLua.ToObject(L, 5);
                LuaFunction  arg4 = ToLua.ToLuaFunction(L, 6);
                object       arg5 = ToLua.ToVarObject(L, 7);
                int          arg6 = (int)LuaDLL.lua_tonumber(L, 8);
                obj.CreatePanel(arg0, arg1, arg2, arg3, arg4, arg5, arg6);
                return(0);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: PanelManager.CreatePanel"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }