예제 #1
0
        private void CreateSerializedBehaviorTree([NotNull] SerializedBehaviorTree serializedBehaviorTree)
        {
            if (m_selectedObject == serializedBehaviorTree)
            {
                return;
            }

            Clear();

            m_serializedGraph = new SerializedBehaviorTreeGraph(serializedBehaviorTree, this)
            {
                name = "Serialized Behavior Tree"
            };
            m_serializedGraph.style.flexGrow = 1f;
            rootVisualElement.Add(m_serializedGraph);

            m_selectedObject = serializedBehaviorTree;
        }
        public SerializedBehaviorTreeGraph([NotNull] SerializedBehaviorTree serializedBehaviorTree,
                                           [NotNull] EditorWindow editorWindow)
        {
            m_serializedBehaviorTree       = serializedBehaviorTree;
            m_serializedBehaviorTreeObject = new SerializedObject(serializedBehaviorTree);
            m_editorWindow         = editorWindow;
            m_searchWindowProvider = ScriptableObject.CreateInstance <SearchWindowProvider>();
            m_searchWindowProvider.Initialize(this);

            SetupZoom(ContentZoomer.DefaultMinScale, ContentZoomer.DefaultMaxScale);

            this.AddManipulator(new ContentDragger());
            this.AddManipulator(new SelectionDragger());
            this.AddManipulator(new RectangleSelector());

            var background = new GridBackground();

            Insert(0, background);
            background.StretchToParentSize();

            var minimap = new MiniMap {
                anchored = true
            };

            minimap.SetPosition(new Rect(10f, 10f, 200f, 200f));
            Add(minimap);

            m_rootNode = new RootNode();
            AddElement(m_rootNode);

            Update();

            graphViewChanged    += OnGraphViewChanged;
            nodeCreationRequest += OnCreateNode;
            m_serializedBehaviorTree.OnAssetChanged += Update;
        }