Пример #1
0
 public UndoNodeMoved(BTEditorGraphNode node)
 {
     m_graph         = node.Graph;
     m_nodeHash      = m_graph.GetNodeHash(node);
     m_startPosition = node.Node.Position;
     m_endPosition   = Vector2.zero;
 }
Пример #2
0
        private void Dispose()
        {
            if (!m_isDisposed)
            {
                if (m_graph != null)
                {
                    BTEditorGraph.DestroyImmediate(m_graph);
                    m_graph = null;
                }
                if (m_btAsset != null)
                {
                    SaveBehaviourTree();
                    m_btAsset.Dispose();
                    m_btAsset = null;
                }

                m_rootTreeAsset = null;

                EditorApplication.playmodeStateChanged -= HandlePlayModeChanged;

                Selection.selectionChanged -= delegate { SetupBTDebugging(); };

                m_isDisposed = true;
            }
        }
Пример #3
0
 public UndoNodeCreated(BTEditorGraphNode node)
 {
     m_graph           = node.Graph;
     m_createdNodeHash = m_graph.GetNodeHash(node);
     m_parentNodeHash  = null;
     m_serializedNode  = null;
     Title             = "Created " + node.Node.Title;
 }
Пример #4
0
        public UndoNodeDeleted(BTEditorGraphNode node, int childIndex)
        {
            m_graph          = node.Graph;
            m_parentNodeHash = m_graph.GetNodeHash(node.Parent);
            m_serializedNode = BTUtils.SerializeNode(node.Node);
            m_childIndex     = childIndex;
            Title            = "Deleted " + node.Node.Title;

            m_createdNodeHash = null;
        }
Пример #5
0
        public static BTEditorGraph Create()
        {
            BTEditorGraph graph = ScriptableObject.CreateInstance <BTEditorGraph>();

            graph.OnCreated();
            graph.hideFlags   = HideFlags.HideAndDontSave;
            graph.m_selection = new List <BTEditorGraphNode>();

            return(graph);
        }
Пример #6
0
        public UndoNodeGroupPush(BTEditorGraphNode node)
        {
            if (!(node.Node is NodeGroup))
            {
                throw new System.ArgumentException("BT graph node is not of type NodeGroup", "node");
            }

            m_graph         = node.Graph;
            m_nodeGroupHash = m_graph.GetNodeHash(node);
            Title           = "Open " + node.Node.Title;
        }
Пример #7
0
        public static BTEditorGraphNode CreateRoot(BTEditorGraph graph, Root node)
        {
            if (graph != null && node != null)
            {
                BTEditorGraphNode graphNode = BTEditorGraphNode.CreateEmptyNode();
                graphNode.m_graph  = graph;
                graphNode.m_parent = null;
                graphNode.SetExistingNode(node);

                return(graphNode);
            }

            return(null);
        }
Пример #8
0
        public static GenericMenu CreateGraphContextMenu(BTEditorGraph graph)
        {
            GenericMenu menu = new GenericMenu();

            if (BTUndoSystem.CanUndo && !graph.ReadOnly)
            {
                BTUndoState topUndo = BTUndoSystem.PeekUndo();
                menu.AddItem(new GUIContent(string.Format("Undo \"{0}\"", topUndo.Title)), false, () => BTUndoSystem.Undo());
            }
            else
            {
                menu.AddDisabledItem(new GUIContent("Undo"));
            }

            if (BTUndoSystem.CanRedo && !graph.ReadOnly)
            {
                BTUndoState topRedo = BTUndoSystem.PeekRedo();
                menu.AddItem(new GUIContent(string.Format("Redo \"{0}\"", topRedo.Title)), false, () => BTUndoSystem.Redo());
            }
            else
            {
                menu.AddDisabledItem(new GUIContent("Redo"));
            }

            menu.AddSeparator("");

            if (!graph.ReadOnly)
            {
                menu.AddItem(new GUIContent("Select All"), false, () => graph.SelectEntireGraph());
            }
            else
            {
                menu.AddDisabledItem(new GUIContent("Select All"));
            }

            menu.AddItem(new GUIContent("Delete All Breakpoints"), false, () => graph.DeleteAllBreakpoints());

            return(menu);
        }
Пример #9
0
        private void OnEnable()
        {
            if (m_gridTexture == null)
            {
                m_gridTexture = Resources.Load <Texture>("BevTree/EditorGUI/background");
            }

            if (m_graph == null)
            {
                m_graph = BTEditorGraph.Create();
            }
            if (m_canvas == null)
            {
                m_canvas = new BTEditorCanvas();
                BTEditorCanvas.Current = m_canvas;
            }
            if (m_hotkeyHandler == null)
            {
                m_hotkeyHandler = new BTEditorHotKeyHandler(m_graph);
            }
            if (m_grid == null)
            {
                m_grid = new BTEditorGrid(m_gridTexture);
            }
            if (m_navigationHistory == null)
            {
                m_navigationHistory = new BTNavigationHistory();
            }

            ReloadBehaviourTree();
            m_isDisposed        = false;
            m_canvas.OnRepaint += OnRepaint;
            EditorApplication.playmodeStateChanged += HandlePlayModeChanged;

            // debugging
            Selection.selectionChanged += delegate { SetupBTDebugging(); };
        }
Пример #10
0
 public BTEditorHotKeyHandler(BTEditorGraph graph)
 {
     m_graph = graph;
 }