Example #1
0
        public static BehaviorTreeEditorView OpenBehaviorTreeWindow()
        {
            BehaviorTreeEditorView openedWindow = CreateWindow <BehaviorTreeEditorView>("Behavior Tree editor");

            openedWindow.saveChangesMessage = "This behavior tree has not been saved. Would you like to save?";
            return(openedWindow);
        }
        public override void OnInspectorGUI()
        {
            BehaviorTreeExecutor treeExecutor = (BehaviorTreeExecutor)target;

            EditorGUI.BeginChangeCheck();
            treeExecutor.tree = (BehaviorTree)EditorGUILayout.ObjectField("Tree", treeExecutor.tree, typeof(BehaviorTree), false);
            if (EditorGUI.EndChangeCheck())
            {
                treeExecutor.RebuildInstanceOverrideList();
            }
            if (GUILayout.Button("Open editor"))
            {
                if (treeExecutor.tree == null)
                {
                    treeExecutor.tree = CreateInstance <BehaviorTree>();
                    treeExecutor.tree.SaveToNew("Behavior Tree");
                }
                BehaviorTreeEditorView.OpenBehaviorTreeWindow().Load(treeExecutor.tree);
            }

            SerializedProperty blackboard = serializedObject.FindProperty("variableOverrides");

            DrawBlackboard(treeExecutor, blackboard);
        }