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();
                }
            }
        }
Esempio n. 2
0
        protected override void OnRaycast(NavMeshPainter targetPainter, RaycastHit hit)
        {
            var t = target as NavMeshLineTool;

            if (t == null)
            {
                return;
            }
            if (Event.current.type == EventType.MouseMove)
            {
                if (m_CurrentState == State.None)
                {
                    t.beginPos = hit.point;
                }
            }
            if (Event.current.type == EventType.MouseDown && Event.current.button == 0)
            {
                if (m_CurrentState == State.None)
                {
                    t.beginPos     = hit.point;
                    t.endPos       = hit.point;
                    m_CurrentState = State.Drag;
                }
            }
            if (Event.current.type == EventType.MouseDrag && Event.current.button == 0)
            {
                if (m_CurrentState == State.Drag)
                {
                    t.endPos = hit.point;
                }
            }
        }
        protected override void OnRaycast(NavMeshPainter targetPainter, RaycastHit hit)
        {
            var t = target as NavMeshBoxTool;

            if (t == null)
            {
                return;
            }
            if (Event.current.type == EventType.MouseMove)
            {
                if (!m_IsDragging)
                {
                    t.beginPos = hit.point;
                }
            }
            if (Event.current.type == EventType.MouseDown && Event.current.button == 0)
            {
                if (!m_IsDragging)
                {
                    t.beginPos   = hit.point;
                    t.endPos     = hit.point;
                    m_IsDragging = true;
                }
            }
            if (Event.current.type == EventType.MouseDrag && Event.current.button == 0)
            {
                if (m_IsDragging)
                {
                    t.endPos = hit.point;
                }
            }
        }
Esempio n. 4
0
        private void Create()
        {
            if (Selection.gameObjects == null || Selection.gameObjects.Length == 0)
            {
                return;
            }
            if (string.IsNullOrEmpty(m_DataPath))
            {
                string savePath = EditorUtility.SaveFilePanel("Save NavMeshPainterData", "", "", "nmptree");
                m_DataPath = FileUtil.GetProjectRelativePath(savePath);
            }
            if (!string.IsNullOrEmpty(m_DataPath))
            {
                NavMeshOcTree data = NavMeshOcTree.Create(Selection.gameObjects, m_ContainChilds, m_Angle * 0.5f, m_MaxDepth,
                                                          m_ForceSetDepth);

                NavMeshOcTree.Save(data, m_DataPath);
            }

            if (m_Painter != null)
            {
                //m_Painter.data = m_Data;
                m_Painter.dataPath = m_DataPath;
                m_Painter.Reload(m_DataPath);
                m_Painter = null;
            }
            m_DataPath = null;
            Close();
        }
Esempio n. 5
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();
                }
            }
        }
Esempio n. 6
0
 static void DrawGizmoForMyScript(NavMeshPainter scr, GizmoType gizmoType)
 {
     if (scr && scr.data != null && SceneView.currentDrawingSceneView && SceneView.currentDrawingSceneView.camera)
     {
         scr.data.DrawGizmos(scr.navMeshWireColor, SceneView.currentDrawingSceneView.camera, scr.lodDeltaDis);
     }
 }
Esempio n. 7
0
    void OnEnable()
    {
        m_Target = (NavMeshPainter)target;

        BuildData();

        List <Transform> transflist = new List <Transform>();

        for (int i = 0; i < m_Target.transform.childCount; i++)
        {
            var        child = m_Target.transform.GetChild(i);
            MeshFilter mf    = child.GetComponent <MeshFilter>();
            if (mf && mf.sharedMesh)
            {
                transflist.Add(child);
            }
            else
            {
                Object.DestroyImmediate(child.gameObject);
            }
        }
        m_Previews = transflist.ToArray();

        ResetCheckerBoard();
        NavMeshEditorUtils.SetMaskTexture(null);
    }
Esempio n. 8
0
        public static void CreateWizard(NavMeshPainter painter = null, string dataPath = null)
        {
            NavMeshPainterCreator creator = NavMeshPainterCreator.DisplayWizard <NavMeshPainterCreator>("NavMeshPainter");

            creator.minSize    = new Vector2(400, 110);
            creator.maxSize    = new Vector2(400, 110);
            creator.m_DataPath = dataPath;
            creator.m_Painter  = painter;
        }
        public void DrawSceneGUI(NavMeshPainter targetPainter)
        {
            RaycastHit hit;

            if (NavMeshEditorUtils.RayCastInSceneView(targetPainter.renderMeshs, out hit))
            {
                OnRaycast(targetPainter, hit);
            }
            OnSceneGUI(targetPainter);
        }
Esempio n. 10
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);
            }
        }
Esempio n. 11
0
        protected override void OnRaycast(NavMeshPainter targetPainter, RaycastHit hit)
        {
            var t = target as NavMeshBrushTool;

            if (t == null)
            {
                return;
            }
            t.position = hit.point;
            if (Event.current.type == EventType.MouseDrag && Event.current.button == 0)
            {
                ApplyPaint();
            }
        }
 protected virtual void OnRaycast(NavMeshPainter targetPainter, RaycastHit hit)
 {
 }
 protected virtual void OnSceneGUI(NavMeshPainter targetPainter)
 {
 }