public TreeGraphView(TreeGraphEditorWindow editorWindow)
        {
            this.editorWindow = editorWindow;
            SetupZoom(0.1f, 4f);

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

            var grid = new GridBackground();

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

            nodeSearcher   = ScriptableObject.CreateInstance <NodeSearcher>();
            actionSearcher = ScriptableObject.CreateInstance <ActionSearcher>();

            nodeSearcher.Initialize(this);
            actionSearcher.Initialize(this);

            edgeConnectorListener = new EdgeConnectorListener(this);
            CreateRootNode();

            nodeCreationRequest = OnNodeCreationRequest;
            graphViewChanged    = OnGraphViewChanged;
        }
Exemple #2
0
 public override void OnInspectorGUI()
 {
     if (!GUILayout.Button("Open Editor"))
     {
         return;
     }
     TreeGraphEditorWindow.Open((BehaviorTreeBlueprintData)target);
 }
Exemple #3
0
        public static bool OpenEditor(int instanceId, int line)
        {
            var data = EditorUtility.InstanceIDToObject(instanceId) as BehaviorTreeBlueprintData;

            if (data == null)
            {
                return(false);
            }

            TreeGraphEditorWindow.Open(data);
            return(true);
        }
        void RecalculateTargetContext()
        {
            TreeGraphEditorWindow window = GraphView.editorWindow;

            if (window.ImportData == null)
            {
                representativeMethods.Clear();
                representativeMethods.Add(null);

                contextSelector.index = 0;
                typeLabel.text        = "No action import data selected";

                return;
            }

            if (true /*Can change target type*/)
            {
                representativeMethods.Clear();
                representativeMethods.Add(null);

                foreach (SerializableMethod method in from import in window.ImportData.actions
                         where import.method != null
                         group import by import.method.TargetContextType
                         into types
                         select types.First().method)
                {
                    representativeMethods.Add(method);
                    if (method.TargetContextType == window.TargetContextType)
                    {
                        contextSelector.index = representativeMethods.Count - 1;
                    }
                }
            }

            typeLabel.text = window.TargetContextType?.ToString() ?? "None";
        }
 public TreeGraphSerializer(TreeGraphEditorWindow editorWindow, TreeGraphView graphView)
 {
     this.editorWindow = editorWindow;
     this.graphView    = graphView;
 }