public void DrawMsgBox(Rect rect, System.Object obj)
        {
            Rect main = Rectangle.GetRect(rect);

            GUI.Box(main, "", GUIStyleCache.GetStyle("WindowBackground"));
            OnDrawMsgBox(main, obj);
        }
        public override Rect DrawHelpBox(ref Rect rect)
        {
            DoDrag(rect);
            Rect drawRect = default(Rect);

            if (dockPosition == DockPosition.Bottom)
            {
                drawRect = new Rect(rect.x, rect.y + rect.height * (1 - weight), rect.width, rect.height * weight);
                rect     = new Rect(rect.x, rect.y, rect.width, rect.height * (1 - weight));
            }
            else if (dockPosition == DockPosition.Top)
            {
                drawRect = new Rect(rect.x, rect.y, rect.width, rect.height * weight);
                rect     = new Rect(rect.x, rect.y + rect.height * weight, rect.width, rect.height * (1 - weight));
            }
            else if (dockPosition == DockPosition.Left)
            {
                drawRect = new Rect(rect.x, rect.y, rect.width * weight, rect.height);
                rect     = new Rect(rect.x + rect.width * weight, rect.y, rect.width * (1 - weight), rect.height);
            }
            else if (dockPosition == DockPosition.Right)
            {
                drawRect = new Rect(rect.x + rect.width * (1 - weight), rect.y, rect.width * weight, rect.height);
                rect     = new Rect(rect.x, rect.y, rect.width * (1 - weight), rect.height);
            }
            GUI.Box(drawRect, string.Empty, GUIStyleCache.GetStyle("WindowBackground"));
            return(drawRect);
        }
Esempio n. 3
0
    protected override Rect DrawMainArea(Rect rect)
    {
        GUI.BeginGroup(rect, GUIStyleCache.GetStyle("GameViewBackground"));
        if (m_PanelBackground == null)
        {
            CreatePanelBackground();
        }

        int tileCountX = Mathf.CeilToInt(rect.width / kTileSize);
        int tileCountY = Mathf.CeilToInt(rect.width / kTileSize);

        if (m_TileCountX != tileCountX || m_TileCountY != tileCountY)
        {
            CheckBoard(rect, tileCountX, tileCountY);
        }

        m_TileCountX = tileCountX;
        m_TileCountY = tileCountY;

        for (int i = -tileCountX; i < 2 * tileCountX; i++)
        {
            for (int j = -tileCountY; j < 2 * tileCountY; j++)
            {
                GUI.DrawTexture(new Rect(rect.x + m_SceneViewPosition.x + i * kTileSize, rect.y + m_SceneViewPosition.y + j * kTileSize, kTileSize, kTileSize), m_PanelBackground);
            }
        }

        GUI.EndGroup();

        ListenDrawMainPanel(rect);

        return(new Rect(rect.x + m_SceneViewPosition.x, rect.y + m_SceneViewPosition.y, m_TileCountX * 2 * kTileSize,
                        m_TileCountY * 2 * kTileSize));
    }
 public override void DrawLeafToolBar(Rect rect)
 {
     base.DrawLeafToolBar(rect);
     if (m_ObjDrawer is ISubWinCustomMenu)
     {
         Rect popRect = new Rect(rect.x + rect.width - 12, rect.y + 7, 13, 11);
         if (GUI.Button(popRect, string.Empty,
                        GUIStyleCache.GetStyle("PaneOptions")))
         {
             GenericMenu menu = new GenericMenu();
             ((ISubWinCustomMenu)m_ObjDrawer).AddCustomMenu(menu);
             if (menu.GetItemCount() > 0)
             {
                 menu.DropDown(popRect);
             }
         }
         rect = new Rect(rect.x + rect.width - 40, rect.y, rect.width - 40, rect.height);
     }
     if (m_ObjDrawer is ISubWinLock)
     {
         EditorGUI.BeginChangeCheck();
         m_IsLock = GUI.Toggle(new Rect(rect.x + rect.width - 20, rect.y + 3, 13, 11), m_IsLock, string.Empty,
                               GUIStyleCache.GetStyle("IN LockButton"));
         if (EditorGUI.EndChangeCheck())
         {
             ((ISubWinLock)m_ObjDrawer).SetLockActive(m_IsLock);
         }
     }
 }
Esempio n. 5
0
 private void DrawFloatingWindow(Vector2 position)
 {
     if (m_CurrentDrag == null)
     {
         return;
     }
     GUI.Box(new Rect(position.x - 50, position.y - 10, 100, 40), m_CurrentDrag.Title,
             GUIStyleCache.GetStyle("window"));
 }
Esempio n. 6
0
        public override void DrawGUI(Rect rect, System.Action repaintAction)
        {
            rect = new Rect(rect.x + 2, rect.y, rect.width - 4, rect.height - 2);


            if (m_TweenParam.isTweening)
            {
                m_TweenParam = GUIEx.ScaleTweenBox(rect, m_TweenParam, m_SubWindows[m_SelectSubWindow].Title,
                                                   GUIStyleCache.GetStyle("dragtabdropwindow"));
                if (repaintAction != null)
                {
                    repaintAction();
                }
                return;
            }

            GUI.BeginGroup(rect, GUIStyleCache.GetStyle("PreBackground"));
            GUI.Box(new Rect(0, 0, rect.width, 18), string.Empty, GUIStyleCache.GetStyle("dockarea"));

            if (m_SelectSubWindow >= 0 && m_SelectSubWindow < m_SubWindows.Count)
            {
                GUI.Label(new Rect(m_SelectSubWindow * 110, 0, rect.width - m_SelectSubWindow * 110, 18),
                          m_SubWindows[m_SelectSubWindow].Title, GUIStyleCache.GetStyle("dragtabdropwindow"));
            }
            for (int i = 0; i < m_SubWindows.Count; i++)
            {
                if (m_SelectSubWindow != i)
                {
                    if (GUI.Button(new Rect(i * 110, 0, 110, 17), m_SubWindows[i].Title, GUIStyleCache.GetStyle("dragtab")))
                    {
                        m_SelectSubWindow = i;
                    }
                }
            }
            GUI.Box(new Rect(0, 18, rect.width, rect.height - 18), string.Empty, GUIStyleCache.GetStyle("hostview"));
            if (m_SelectSubWindow >= 0 && m_SelectSubWindow < m_SubWindows.Count)
            {
                GUI.BeginGroup(new Rect(0, 18, rect.width, rect.height - 18));
                m_SubWindows[m_SelectSubWindow].DrawSubWindow(new Rect(0, 0, rect.width, rect.height - 18));
                GUI.EndGroup();
                if (repaintAction != null)
                {
                    repaintAction();
                }
            }

            if (m_SelectSubWindow >= 0 && m_SelectSubWindow < m_SubWindows.Count)
            {
                m_SubWindows[m_SelectSubWindow].DrawToolBarExt(new Rect(rect.width - 100, 0, 100, 18));
            }

            GUI.EndGroup();
            this.rect = rect;
        }
Esempio n. 7
0
 public override void DrawMsgBox(Rect rect, object obj)
 {
     base.DrawMsgBox(rect, obj);
     GUI.Box(new Rect(rect.x, rect.y, rect.width, 18), string.Empty, GUIStyleCache.GetStyle("Toolbar"));
     if (GUI.Button(new Rect(rect.x + rect.width - 21, rect.y + 4, 13, 11), string.Empty, GUIStyleCache.GetStyle("WinBtnClose")))
     {
         CloseMsgBox();
     }
     GUI.Label(new Rect(rect.x, rect.y + 30, rect.width, 20), "XXXXXXXXXXXXXX");
     m_Value = EditorGUI.Vector3Field(new Rect(rect.x, rect.y + 50, rect.width, 20), "Value:", m_Value);
 }
 private void DrawPreview(Rect rect, Rect toolbar)
 {
     if (GUI.Button(new Rect(toolbar.x + 10, toolbar.y, 90, 15), "从文件加载深度图", GUIStyleCache.GetStyle("MiniToolBarButton")))
     {
         UnlitWaterUtils.LoadTexture(ref m_Texture);
     }
     if (GUI.Button(new Rect(toolbar.x + 100, toolbar.y, 90, 15), "保存深度图", GUIStyleCache.GetStyle("MiniToolBarButton")))
     {
         UnlitWaterUtils.SaveTexture(m_Texture);
     }
     if (m_Texture)
     {
         Rect previewRect = DrawPreviewTexture(rect);
         GUI.DrawTexture(previewRect, m_Texture);
     }
 }
 public Rect DrawToolBar(ref Rect rect)
 {
     if (toolBar == EWSubWindowToolbarType.Normal)
     {
         Rect h = new Rect(rect.x, rect.y, rect.width, 18);
         rect = new Rect(rect.x, rect.y + 18, rect.width, rect.height - 18);
         GUI.Box(h, string.Empty, GUIStyleCache.GetStyle("Toolbar"));
         return(h);
     }
     else if (toolBar == EWSubWindowToolbarType.Mini)
     {
         Rect h = new Rect(rect.x, rect.y, rect.width, 15);
         rect = new Rect(rect.x, rect.y + 15, rect.width, rect.height - 15);
         GUI.Box(h, string.Empty, GUIStyleCache.GetStyle("MiniToolbarButton"));
         return(h);
     }
     return(new Rect(rect.x, rect.y, 0, 0));
 }
Esempio n. 10
0
    void OnGUI()
    {
        bool guienable = GUI.enabled;

        if (m_MsgBox != null && m_MsgBox.IsShowing)
        {
            GUI.enabled = false;
        }
        else
        {
            GUI.enabled = true;
        }
        GUI.BeginGroup(new Rect(0, 0, position.width, position.height), GUIStyleCache.GetStyle("LODBlackBox"));
        OnDrawGUI();
        GUI.EndGroup();

        GUI.enabled = guienable;
        DrawMsgBox(new Rect(0, 0, position.width, position.height));
    }
Esempio n. 11
0
        protected override bool TriggerAnchorArea(Vector2 position, int depth, SubWindow window,
                                                  System.Action <SubWindow> preDropAction, System.Action postDropAction)
        {
            if (m_TweenParam.isTweening)
            {
                return(false);
            }
            if (depth >= kMaxNodeDepth)
            {
                return(false);
            }
            if (m_SubWindows.Count >= kMaxSubWindowCount)
            {
                return(false);
            }
            if (this.m_SubWindows.Contains(window))
            {
                return(false);
            }
            Rect rect = new Rect(this.rect.x, this.rect.y, this.rect.width, 17);

            if (rect.Contains(position))
            {
                if (preDropAction == null)
                {
                    tweenParam = GUIEx.ScaleTweenBox(rect, tweenParam, string.Empty,
                                                     GUIStyleCache.GetStyle("SelectionRect"));
                }
                else
                {
                    if (preDropAction != null)
                    {
                        preDropAction(window);
                        this.AddWindow(window, 0);
                        postDropAction();
                    }
                }
                return(true);
            }
            return(false);
        }
Esempio n. 12
0
 /// <summary>
 /// 绘制工具栏
 /// </summary>
 /// <param name="rect"></param>
 protected void DrawToolbar(Rect rect)
 {
     GUI.Box(rect, string.Empty, GUIStyleCache.GetStyle("Toolbar"));
     if (m_WindowTree != null)
     {
         m_WindowTree.DrawLayoutButton(new Rect(rect.x + rect.width - 80, rect.y, 70, rect.height));
     }
     GUILayout.BeginArea(new Rect(rect.x + 10, rect.y, rect.width - 100, rect.height));
     GUILayout.BeginHorizontal();
     if (m_ToolbarTree != null)
     {
         m_ToolbarTree.DrawToolbar();
     }
     if (m_WindowTree != null)
     {
         m_WindowTree.DrawViewButton();
     }
     OnDrawToolBar();
     GUILayout.EndHorizontal();
     GUILayout.EndArea();
 }
        public override Rect DrawHelpBox(ref Rect rect)
        {
            if (m_IsLock)
            {
                Rect lockerRect = new Rect(rect.x, rect.y + rect.height - 18, rect.width, 18);
                rect = new Rect(rect.x, rect.y, rect.width, rect.height - 18);
                GUI.Box(lockerRect, string.Empty, EditorStyles.toolbar);
                GUI.Box(new Rect(lockerRect.x + 20, lockerRect.y + 6, lockerRect.width - 40, lockerRect.height - 6), string.Empty,
                        GUIStyleCache.GetStyle("WindowBottomResize"));
                EditorGUIUtility.AddCursorRect(lockerRect, MouseCursor.ResizeVertical);
                if (Event.current.type == EventType.MouseDown && Event.current.button == 0)
                {
                    if (lockerRect.Contains(Event.current.mousePosition))
                    {
                        Event.current.Use();
                        m_IsLock = false;
                    }
                }
                return(new Rect(rect.x, rect.y, 0, 0));
            }
            else
            {
                DoDrag(rect);
                Rect drawRect   = new Rect(rect.x, rect.y + rect.height * (1 - weight), rect.width, rect.height * weight);
                Rect lockerRect = new Rect(rect.x, rect.y + rect.height * (1 - weight) - 9, rect.width, 18);
                rect = new Rect(rect.x, rect.y, rect.width, rect.height * (1 - weight) - 9);

                GUI.Box(drawRect, string.Empty, GUIStyleCache.GetStyle("WindowBackground"));
                GUI.Box(lockerRect, string.Empty, EditorStyles.toolbar);
                GUI.Box(new Rect(lockerRect.x + 20, lockerRect.y + 6, lockerRect.width - 40, lockerRect.height - 6), string.Empty,
                        GUIStyleCache.GetStyle("WindowBottomResize"));
                if (weight <= 0.08f)
                {
                    weight   = 0.1f;
                    m_IsLock = true;
                }
                return(drawRect);
            }
        }
Esempio n. 14
0
    public static GUIStyle GetStyle(string style)
    {
        if (instance == null)
        {
            instance = new GUIStyleCache();
        }
        if (instance.m_StyleCache == null)
        {
            instance.m_StyleCache = new Dictionary <string, GUIStyle>();
        }
        GUIStyle st = null;

        if (instance.m_StyleCache.ContainsKey(style))
        {
            st = instance.m_StyleCache[style];
        }
        if (st == null)
        {
            st = style;
            instance.m_StyleCache[style] = st;
        }
        return(st);
    }
Esempio n. 15
0
 /// <summary>
 /// 绘制工具栏-布局按钮
 /// </summary>
 /// <param name="rect"></param>
 public void DrawLayoutButton(Rect rect)
 {
     if (GUI.Button(rect, "Layout", GUIStyleCache.GetStyle("ToolbarDropDown")))
     {
         if (m_Layout != null)
         {
             GenericMenu menu = new GenericMenu();
             menu.AddItem(new GUIContent("Default"), false, this.UseDefaultLayout);
             if (m_Layout.Layouts != null && m_Layout.Layouts.Count > 0)
             {
                 for (int i = 0; i < m_Layout.Layouts.Count; i++)
                 {
                     menu.AddItem(new GUIContent(m_Layout.Layouts[i]), false, this.OnUseLayout,
                                  m_Layout.Layouts[i]);
                 }
             }
             menu.AddSeparator("");
             menu.AddItem(new GUIContent("Save Layout..."), false, this.OnSaveLayout);
             menu.AddItem(new GUIContent("Delete Layout..."), false, this.OnDeleteLayout);
             menu.AddItem(new GUIContent("Clear All Layout..."), false, this.OnRevertLayout);
             menu.DropDown(rect);
         }
     }
 }
Esempio n. 16
0
    protected override Rect DrawMainArea(Rect rect)
    {
        GUI.Box(rect, string.Empty, GUIStyleCache.GetStyle("GameViewBackground"));

        return(rect);
    }
Esempio n. 17
0
        /// <summary>
        /// 触发锚点区域
        /// </summary>
        /// <param name="position"></param>
        /// <param name="depth"></param>
        /// <param name="window"></param>
        /// <param name="preDropAction"></param>
        /// <param name="postDropAction"></param>
        /// <returns></returns>
        protected virtual bool TriggerAnchorArea(Vector2 position, int depth, SubWindow window,
                                                 System.Action <SubWindow> preDropAction, System.Action postDropAction)
        {
            if (depth >= kMaxNodeDepth)
            {
                return(false);
            }
            Rect  r      = default(Rect);
            float offset = 0;

            for (int i = 0; i < m_Childs.Count; i++)
            {
                if (m_Childs[i].TriggerAnchorArea(position, depth + 1, window, preDropAction, postDropAction))
                {
                    return(true);
                }
                if (isHorizontal)
                {
                    r = new Rect(rect.x + offset, rect.y, rect.width * m_Childs[i].weight * 0.2f, rect.height);
                    if (r.Contains(position))
                    {
                        if (preDropAction == null)
                        {
                            tweenParam = GUIEx.ScaleTweenBox(r, tweenParam, string.Empty,
                                                             GUIStyleCache.GetStyle("SelectionRect"));
                        }
                        else
                        {
                            this.DropWindow(window, preDropAction, postDropAction, true, i);
                        }
                        return(true);
                    }
                    r = new Rect(rect.x + offset + rect.width * m_Childs[i].weight * 0.8f, rect.y,
                                 rect.width * m_Childs[i].weight * 0.2f, rect.height);
                    if (r.Contains(position))
                    {
                        if (preDropAction == null)
                        {
                            tweenParam = GUIEx.ScaleTweenBox(r, tweenParam, string.Empty,
                                                             GUIStyleCache.GetStyle("SelectionRect"));
                        }
                        else
                        {
                            this.DropWindow(window, preDropAction, postDropAction, true, i + 1);
                        }
                        return(true);
                    }
                    r = new Rect(rect.x + offset, rect.y + rect.height * 0.8f, rect.width * m_Childs[i].weight,
                                 rect.height * 0.2f);
                    if (r.Contains(position) && m_Childs.Count > 1)
                    {
                        if (preDropAction == null)
                        {
                            tweenParam = GUIEx.ScaleTweenBox(r, tweenParam, string.Empty,
                                                             GUIStyleCache.GetStyle("SelectionRect"));
                        }
                        else
                        {
                            this.DropWindow(window, preDropAction, postDropAction, false, i);
                        }
                        return(true);
                    }
                    offset += m_Childs[i].weight * rect.width;
                }
                else
                {
                    r = new Rect(rect.x, rect.y + offset, rect.width, rect.height * m_Childs[i].weight * 0.2f);
                    if (r.Contains(position))
                    {
                        if (preDropAction == null)
                        {
                            tweenParam = GUIEx.ScaleTweenBox(r, tweenParam, string.Empty,
                                                             GUIStyleCache.GetStyle("SelectionRect"));
                        }
                        else
                        {
                            this.DropWindow(window, preDropAction, postDropAction, true, i);
                        }
                        return(true);
                    }
                    r = new Rect(rect.x, rect.y + offset + rect.height * m_Childs[i].weight * 0.8f, rect.width,
                                 rect.height * m_Childs[i].weight * 0.2f);
                    if (r.Contains(position))
                    {
                        if (preDropAction == null)
                        {
                            tweenParam = GUIEx.ScaleTweenBox(r, tweenParam, string.Empty,
                                                             GUIStyleCache.GetStyle("SelectionRect"));
                        }
                        else
                        {
                            this.DropWindow(window, preDropAction, postDropAction, true, i + 1);
                        }
                        return(true);
                    }
                    r = new Rect(rect.x + rect.width * 0.8f, rect.y + offset, rect.width * 0.2f,
                                 rect.height * m_Childs[i].weight);
                    if (r.Contains(position) && m_Childs.Count > 1)
                    {
                        if (preDropAction == null)
                        {
                            tweenParam = GUIEx.ScaleTweenBox(r, tweenParam, string.Empty,
                                                             GUIStyleCache.GetStyle("SelectionRect"));
                        }
                        else
                        {
                            this.DropWindow(window, preDropAction, postDropAction, false, i);
                        }
                        return(true);
                    }
                    offset += m_Childs[i].weight * rect.height;
                }
            }
            return(false);
        }
Esempio n. 18
0
    private void DrawBakeSetting(Rect rect)
    {
        bool guienable = GUI.enabled;

        GUI.enabled = guienable && m_Painter.paintVertexChannel == UnlitWaterPainter.Channel.None;
        GUI.BeginGroup(new Rect(rect.x + 5, rect.y + 5, rect.width - 10, rect.height - 10));

        GUI.enabled = (int)m_TargetErrorDef <= (int)TargetErrorDef.WillReplaceMesh && m_TargetGameObject && m_Painter.paintVertexChannel == UnlitWaterPainter.Channel.None && guienable;
        GUI.Label(new Rect(0, 0, position.width - 10, 17), "区域设置");
        m_MaxHeight = Mathf.Max(0,
                                EditorGUI.FloatField(new Rect(0, 20, rect.width - 10, 17),
                                                     new GUIContent("上方高度", EditorGUIUtility.FindTexture("console.erroricon.inactive.sml"), "调整上方高度直到超过所有物体"),
                                                     m_MaxHeight));
        m_MinHeight = Mathf.Max(0,
                                EditorGUI.FloatField(new Rect(0, 40, rect.width - 10, 17),
                                                     new GUIContent("下方高度", EditorGUIUtility.FindTexture("console.erroricon.inactive.sml"), "调整下方高度直到刚好超过水底最深处"),
                                                     m_MinHeight));

        GUI.enabled   = (int)m_TargetErrorDef <= (int)TargetErrorDef.WillReplaceMesh && m_TargetGameObject && m_Painter.paintVertexChannel == UnlitWaterPainter.Channel.None && guienable && m_MeshGeneratorType == MeshGeneratorType.ModelFile;
        m_LocalCenter = EditorGUI.Vector2Field(new Rect(0, 60, rect.width - 10, 40),
                                               new GUIContent("位置偏移", EditorGUIUtility.FindTexture("console.erroricon.inactive.sml"), "调整渲染区域的坐标偏移"),
                                               m_LocalCenter);


        GUI.enabled = (int)m_TargetErrorDef <= (int)TargetErrorDef.WillReplaceMesh && m_TargetGameObject && m_Painter.paintVertexChannel == UnlitWaterPainter.Channel.None && guienable;
        m_RotY      = EditorGUI.FloatField(new Rect(0, 100, rect.width - 10, 17),
                                           new GUIContent("Y轴旋转", EditorGUIUtility.FindTexture("console.erroricon.inactive.sml"), "调整渲染区域的Y轴旋转"),
                                           m_RotY);

        GUI.Label(new Rect(0, 120, position.width - 10, 17), "渲染设置");
        m_MaxDepth = Mathf.Max(0,
                               EditorGUI.FloatField(new Rect(0, 140, rect.width - 10, 17),
                                                    new GUIContent("最大深度范围", EditorGUIUtility.FindTexture("console.erroricon.inactive.sml"), "控制渲染的最大深度范围,默认为1"),
                                                    m_MaxDepth));
        m_DepthPower = Mathf.Max(0,
                                 EditorGUI.FloatField(new Rect(0, 160, rect.width - 10, 17),
                                                      new GUIContent("深度增强", EditorGUIUtility.FindTexture("console.erroricon.inactive.sml"), "控制渲染深度的效果增强或减弱,默认为1表示不增强"),
                                                      m_DepthPower));

        if (GUI.Button(new Rect(0, 220, (rect.width - 10) / 2, 16), "渲染", GUIStyleCache.GetStyle("ButtonLeft")))
        {
            Vector2 size = m_Factory.GetSize(m_MeshGeneratorType);
            UnlitWaterUtils.RenderDepthTexture(m_TargetGameObject, m_LocalCenter, size,
                                               Quaternion.Euler(90, m_RotY, 0), m_MaxHeight, m_MinHeight, m_MaxDepth, m_DepthPower, ref m_Texture);
        }
        GUI.enabled = m_Texture != null && m_Painter.paintVertexChannel == UnlitWaterPainter.Channel.None && guienable;
        if (m_MeshGeneratorType != MeshGeneratorType.ModelFile)
        {
            if (GUI.Button(new Rect((rect.width - 10) / 2, 220, (rect.width - 10) / 2, 16), "生成Mesh",
                           GUIStyleCache.GetStyle("ButtonRight")))
            {
                UnlitWaterUtils.GenerateMesh(m_TargetGameObject, m_Texture, meshGenerator);
            }
        }
        else
        {
            if (GUI.Button(new Rect((rect.width - 10) / 2, 220, (rect.width - 10) / 2, 16), "应用到顶点色",
                           GUIStyleCache.GetStyle("ButtonRight")))
            {
                UnlitWaterUtils.ApplyToVertexColor(m_TargetGameObject, m_Texture, m_LocalCenter, m_Factory.GetSize(m_MeshGeneratorType), m_MinHeight, m_MaxHeight);
            }
        }

        GUI.enabled = guienable;
        GUI.EndGroup();
    }
Esempio n. 19
0
    private void DrawBakeSetting(Rect rect)
    {
        bool guienable = GUI.enabled;

        GUI.enabled = guienable && m_Painter.paintVertexChannel == UnlitWaterPainter.Channel.None;
        GUI.BeginGroup(new Rect(rect.x + 5, rect.y + 5, rect.width - 10, rect.height - 10));

        GUI.enabled = (int)m_TargetErrorDef <= (int)TargetErrorDef.WillReplaceMesh && m_TargetGameObject && m_Painter.paintVertexChannel == UnlitWaterPainter.Channel.None && guienable;
        GUI.Label(new Rect(0, 0, position.width - 10, 17), "区域设置");
        m_MaxHeight = Mathf.Max(0,
                                EditorGUI.FloatField(new Rect(0, 20, rect.width - 10, 17),
                                                     new GUIContent("上方高度", EditorGUIUtility.FindTexture("console.erroricon.inactive.sml"), "调整上方高度直到超过所有物体"),
                                                     m_MaxHeight));
        m_MinHeight = Mathf.Max(0,
                                EditorGUI.FloatField(new Rect(0, 40, rect.width - 10, 17),
                                                     new GUIContent("下方高度", EditorGUIUtility.FindTexture("console.erroricon.inactive.sml"), "调整下方高度直到刚好超过水底最深处"),
                                                     m_MinHeight));

        GUI.enabled   = (int)m_TargetErrorDef <= (int)TargetErrorDef.WillReplaceMesh && m_TargetGameObject && m_Painter.paintVertexChannel == UnlitWaterPainter.Channel.None && guienable && m_MeshGeneratorType == MeshGeneratorType.ModelFile;
        m_LocalCenter = EditorGUI.Vector2Field(new Rect(0, 60, rect.width - 10, 40),
                                               new GUIContent("位置偏移", EditorGUIUtility.FindTexture("console.erroricon.inactive.sml"), "调整渲染区域的坐标偏移"),
                                               m_LocalCenter);


        GUI.enabled = (int)m_TargetErrorDef <= (int)TargetErrorDef.WillReplaceMesh && m_TargetGameObject && m_Painter.paintVertexChannel == UnlitWaterPainter.Channel.None && guienable;
        m_RotY      = EditorGUI.FloatField(new Rect(0, 100, rect.width - 10, 17),
                                           new GUIContent("Y轴旋转", EditorGUIUtility.FindTexture("console.erroricon.inactive.sml"), "调整渲染区域的Y轴旋转"),
                                           m_RotY);

        GUI.Label(new Rect(0, 120, position.width - 10, 17), "渲染设置");
        m_TextureRendererType = (TextureRendererType)EditorGUI.EnumPopup(new Rect(0, 140, rect.width - 10, 17), "贴图渲染器类型", m_TextureRendererType);


        GUILayout.BeginArea(new Rect(0, 160, rect.width - 10, rect.height - 160));

        TextureRenderer renderer = textureRenderer;

        if (renderer != null)
        {
            renderer.DrawGUI();
        }

        EditorGUILayout.Space();
        GUILayout.BeginHorizontal();
        if (GUILayout.Button("渲染", GUIStyleCache.GetStyle("ButtonLeft"), GUILayout.Width(rect.width * 0.5f - 5)))
        {
            if (renderer != null)
            {
                Vector2 size = m_MeshGeneratorFactory.GetSize(m_MeshGeneratorType);
                renderer.RenderDepthTexture(m_TargetGameObject, m_LocalCenter, size,
                                            Quaternion.Euler(90, m_RotY, 0), m_MaxHeight, m_MinHeight, ref m_Texture);
            }
        }
        GUI.enabled = m_Texture != null && m_Painter.paintVertexChannel == UnlitWaterPainter.Channel.None && guienable;
        if (m_MeshGeneratorType != MeshGeneratorType.ModelFile)
        {
            if (GUILayout.Button("生成Mesh", GUIStyleCache.GetStyle("ButtonRight")))
            {
                UnlitWaterUtils.GenerateMesh(m_TargetGameObject, m_Texture, meshGenerator);
            }
        }
        else
        {
            if (GUILayout.Button("应用到顶点色", GUIStyleCache.GetStyle("ButtonRight")))
            {
                UnlitWaterUtils.ApplyToVertexColor(m_TargetGameObject, m_Texture, m_LocalCenter, m_MeshGeneratorFactory.GetSize(m_MeshGeneratorType), m_MinHeight, m_MaxHeight);
            }
        }
        GUILayout.EndHorizontal();

        GUI.enabled = guienable;

        GUILayout.EndArea();

        GUI.EndGroup();
    }
Esempio n. 20
0
 /// <summary>
 /// 绘制工具栏区域
 /// </summary>
 /// <param name="rect"></param>
 public void DrawToolBarExt(Rect rect)
 {
     if (GUI.Button(new Rect(rect.x + rect.width - 21, rect.y + 2, 13, 13), string.Empty, GUIStyleCache.GetStyle("WinBtnClose")))
     {
         Close();
     }
     m_Drawer.DrawLeafToolBar(new Rect(rect.x, rect.y, rect.width - 27, rect.height));
 }