예제 #1
0
        private void OnEnable()
        {
            if (m_gridTexture == null)
            {
                m_gridTexture = Resources.Load <Texture>("Brainiac/EditorGUI/background");
            }

            if (m_graph == null)
            {
                m_graph = BTEditorGraph.Create();
            }
            if (m_canvas == null)
            {
                m_canvas = new BTEditorCanvas();
                BTEditorCanvas.Current = m_canvas;
            }
            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;
        }
예제 #2
0
 public UndoNodeMoved(BTEditorGraphNode node)
 {
     m_graph         = node.Graph;
     m_nodeHash      = m_graph.GetNodeHash(node);
     m_startPosition = node.Node.Position;
     m_endPosition   = Vector2.zero;
 }
예제 #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 static BTEditorGraph Create()
        {
            BTEditorGraph graph = ScriptableObject.CreateInstance <BTEditorGraph>();

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

            return(graph);
        }
예제 #5
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;
        }
예제 #6
0
        public UndoNodeGroupPop(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           = "Close " + (string.IsNullOrEmpty(node.Node.Name) ? node.Node.Title : node.Node.Name);
        }
예제 #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
        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();
                }

                EditorApplication.playmodeStateChanged -= HandlePlayModeChanged;
                m_isDisposed = true;
            }
        }
예제 #9
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);
        }