static void OpenBehaviorTreeWin()
        {
            BehaviorTreeWindow_Win         = EditorWindow.GetWindow <BehaviorTreeWindow>("行为树编辑器");
            BehaviorTreeWindow_Win.minSize = Constants.BehaviorTreeWinMinSize;
            BehaviorTreeWindow_Win.Show();

            // EditorApplication.update += OnEditorUpdate;
        }
Esempio n. 2
0
        public override void OnHandleEvent(Event e)
        {
            if (BehaviorTreeWindow.CurFocusMenu != this)
            {
                Debug.Log("OnHandleEvent  " + BehaviorTreeWindow.CurFocusMenu);
                return;
            }
            //Debug.Log("vvvvvvvvvvvvv " + e.type);
            switch (e.type)
            {
            case EventType.MouseDown:
                UpdateNodesState(true);
                CheckIfTryMoveNode();
                Debug.Log(m_MenuName + "MouseDown::  " + e.type);
                if (NodeActionContexMenu_ContexMenu != null)
                {
                    NodeActionContexMenu_ContexMenu.ShowOrHideContex(false);
                }
                break;

            case EventType.ContextClick:               //右键
                BehaviorTreeWindow.ForceRepaintView(); //重绘
                Debug.Log(m_MenuName + "ContextClick::  " + e.type);
                if (NodeActionContexMenu_ContexMenu != null)
                {
                    NodeActionContexMenu_ContexMenu.ShowOrHideContex(true);
                    Vector2 mouseReletivePos = Event.current.mousePosition - new Vector2(m_CurShowArea.x, m_CurShowArea.y); //光标相对于父窗口的坐标
                    m_NodeActionContexMenu.UpdateShowPosition(mouseReletivePos);                                            //更新右键菜单的位置
                }
                //Debug.Log(m_MenuName + "::  " + e.type);
                break;

            case EventType.DragPerform:
                //    Debug.Log("EventType.DragPerform");
                break;

            case EventType.MouseDrag:
                //Debug.Log("EventType.MouseDrag");
                BehaviorTreeWindow.ForceRepaintView();     //重绘
                if (NodeParent.m_SelectNodeLineBegin == null)
                {
                    foreach (var node in m_AllSelectedNodes)
                    {
                        node.Value.m_EditorNode.MoveNode(BehaviorTreeWindow.m_MouseDetail);
                    }
                }
                break;

            case EventType.MouseUp:
                UpdateNodesState(false);
                //Debug.Log("EventType.MouseUp");
                m_AllSelectedNodes.Clear();
                TryConnectLinePoint();
                NodeParent.m_SelectNodeLineBegin = NodeParent.m_SelectNodeLineEnd = null;
                BehaviorTreeWindow.ForceRepaintView();     //重绘
                break;
            }
        }