コード例 #1
0
        internal void InstantiateNodeView(SerializedBTNode nodeView)
        {
            BTNodeView node = new BTNodeView(nodeView);

            node.onNodeSelected += _updateInspector;
            AddElement(node);
        }
コード例 #2
0
        public void Update(BTNodeView inspect)
        {
            Clear();
            UnityEngine.Object.DestroyImmediate(_editor);

            _editor = Editor.CreateEditor(inspect.SerializedNode);
            if (_editor)
            {
                IMGUIContainer container = new IMGUIContainer(_editor.OnInspectorGUI);
                Add(container);
            }
        }
コード例 #3
0
        private void CreateEdges(SerializedBTNode node)
        {
            var childs = node.childs;

            if (childs != null && childs.Count > 0)
            {
                BTNodeView parentView = GetNodeByGuid(node.guid) as BTNodeView;
                foreach (var child in childs)
                {
                    var childView = GetNodeByGuid(child.guid) as BTNodeView;

                    var edge = parentView.ConnectTo(childView.GetInput());
                    AddElement(edge);
                }
            }
        }
コード例 #4
0
        private GraphViewChange OnGraphViewChanged(GraphViewChange graphViewChange)
        {
            var toRemove = graphViewChange;

            if (graphViewChange.elementsToRemove != null)
            {
                foreach (GraphElement remove in graphViewChange.elementsToRemove)
                {
                    BTNodeView nodeView = remove as BTNodeView;
                    if (nodeView != null)
                    {
                        if (nodeView.SerializedNode == _btAsset.Root)
                        {
                            toRemove.elementsToRemove.Remove(remove);
                            break;
                        }
                        _btAsset.RemoveNode(nodeView.SerializedNode);
                    }

                    Edge edge = remove as Edge;
                    if (edge != null)
                    {
                        BTNodeView parent = edge.output.node as BTNodeView;
                        BTNodeView child  = edge.input.node as BTNodeView;
                        parent.SerializedNode.RemoveChild(child.SerializedNode);
                    }
                }
            }

            if (graphViewChange.edgesToCreate != null)
            {
                foreach (Edge edge in graphViewChange.edgesToCreate)
                {
                    BTNodeView parent = edge.output.node as BTNodeView;
                    BTNodeView child  = edge.input.node as BTNodeView;
                    parent.SerializedNode.AddChild(child.SerializedNode);
                }
            }

            return(toRemove);
        }