protected override void OnSceneGUI(NavMeshPainter targetPainter)
        {
            NavMeshEditorUtils.ClearBrush();
            var t = target as NavMeshBoxTool;

            if (t == null)
            {
                return;
            }
            if (m_IsDragging)
            {
                NavMeshEditorUtils.DrawBounds(t.bounds, Color.blue);
            }
            else
            {
                NavMeshEditorUtils.DrawWireCube(t.beginPos, new Vector3(1, t.bottomHeight + t.topHeight, 1), Color.blue);
            }
            if (Event.current.type == EventType.MouseUp)
            {
                if (m_IsDragging)
                {
                    m_IsDragging = false;
                    ApplyPaint();
                }
            }
        }
示例#2
0
        protected override void OnSceneGUI(NavMeshPainter targetPainter)
        {
            NavMeshEditorUtils.ClearBrush();
            var t = target as NavMeshLineTool;

            if (t == null)
            {
                return;
            }
            if (m_CurrentState == State.Drag)
            {
                DrawArea(t, Color.blue);
            }
            else
            {
                NavMeshEditorUtils.DrawWireCube(t.beginPos, new Vector3(t.width, t.height, t.width), Color.blue);
            }
            if (Event.current.type == EventType.MouseUp)
            {
                if (m_CurrentState == State.Drag)
                {
                    m_CurrentState = State.None;
                    ApplyPaint();
                }
            }
        }
示例#3
0
        private void DrawArea(NavMeshLineTool tool, Color color)
        {
            Vector3 toEnd = tool.endPos - tool.beginPos;

            Vector3 hVector = Vector3.Cross(toEnd, Vector3.up).normalized;

            Vector3 p0 = tool.beginPos - hVector * tool.width * 0.5f - Vector3.up * tool.height;
            Vector3 p1 = tool.beginPos - hVector * tool.width * 0.5f + Vector3.up * tool.height;
            Vector3 p2 = tool.beginPos + hVector * tool.width * 0.5f + Vector3.up * tool.height;
            Vector3 p3 = tool.beginPos + hVector * tool.width * 0.5f - Vector3.up * tool.height;

            Vector3 p4 = tool.endPos - hVector * tool.width * 0.5f - Vector3.up * tool.height;
            Vector3 p5 = tool.endPos - hVector * tool.width * 0.5f + Vector3.up * tool.height;
            Vector3 p6 = tool.endPos + hVector * tool.width * 0.5f + Vector3.up * tool.height;
            Vector3 p7 = tool.endPos + hVector * tool.width * 0.5f - Vector3.up * tool.height;

            NavMeshEditorUtils.DrawLine(p0, p1, color);
            NavMeshEditorUtils.DrawLine(p1, p2, color);
            NavMeshEditorUtils.DrawLine(p2, p3, color);
            NavMeshEditorUtils.DrawLine(p3, p0, color);

            NavMeshEditorUtils.DrawLine(p4, p5, color);
            NavMeshEditorUtils.DrawLine(p5, p6, color);
            NavMeshEditorUtils.DrawLine(p6, p7, color);
            NavMeshEditorUtils.DrawLine(p7, p4, color);

            NavMeshEditorUtils.DrawLine(p0, p4, color);
            NavMeshEditorUtils.DrawLine(p1, p5, color);
            NavMeshEditorUtils.DrawLine(p2, p6, color);
            NavMeshEditorUtils.DrawLine(p3, p7, color);
        }
        public void DrawSceneGUI(NavMeshPainter targetPainter)
        {
            RaycastHit hit;

            if (NavMeshEditorUtils.RayCastInSceneView(targetPainter.renderMeshs, out hit))
            {
                OnRaycast(targetPainter, hit);
            }
            OnSceneGUI(targetPainter);
        }
示例#5
0
        protected override void OnSceneGUI(NavMeshPainter targetPainter)
        {
            var t = this.target as NavMeshBrushTool;

            if (t != null)
            {
                NavMeshEditorUtils.DrawBounds(t.bounds, Color.blue);
                NavMeshEditorUtils.DrawBrush(targetPainter.renderMeshs, Matrix4x4.identity, t.position, t.length, t.width, t.height,
                                             t.brushType);
            }
        }