protected BehaviourTreeUI.TreeGraph GetNewTree(AI.BehaviorTree sourceTree) { //Initialize tree scriptable object BehaviourTreeUI.TreeGraph uiTree = ScriptableObject.CreateInstance <BehaviourTreeUI.TreeGraph>(); //Save scriptable object // string treePath = editorPath + "/" + treeFolder; if (!AssetDatabase.IsValidFolder(treePath)) { AssetDatabase.CreateFolder(editorPath, treeFolder); } string fileName = sourceTree.name + fileNameSuffix; AssetDatabase.CreateAsset(uiTree, treePath + "/" + fileName + ".asset"); AssetDatabase.CreateFolder(treePath, fileName); AssetDatabase.SaveAssets(); // //Generate tree // uiTree.Tree = target as AI.BehaviorTree; uiTree.graphNodeFolderPath = treePath + "/" + fileName; uiTree.CreateTree(); // return(uiTree); }
public override void OnGraphGUI() { base.OnGraphGUI(); if (graph is TreeGraph) { TreeGraph t = graph as TreeGraph; t.Validate(); } }
public static void DoTree(TreeGraph tree) { graphEditorWindow = GetWindow <BehaviourTreeGraphEditorWindow>(); graphEditorWindow.behaviourTreeGraph = tree; graphEditorWindow.behaviourTreeGraphGUI = ScriptableObject.CreateInstance <GraphGUIEX>(); graphEditorWindow.behaviourTreeGraphGUI.graph = graphEditorWindow.behaviourTreeGraph; graphEditorWindow._toolbarItems.Clear(); AddToolBarItem("Save Tree", graphEditorWindow.behaviourTreeGraph.SaveGraphToSources); AddToolBarItem("New Leaf Node", graphEditorWindow.CreateNewLeaf); AddToolBarItem("New Selector Node", graphEditorWindow.CreateNewSelector); AddToolBarItem("New Sequence Node", graphEditorWindow.CreateNewSequence); }
protected BehaviourTreeUI.TreeGraph GetTree(AI.BehaviorTree sourceTree) { string treePath = editorPath + "/" + treeFolder; string fileName = sourceTree.name + fileNameSuffix + ".asset"; BehaviourTreeUI.TreeGraph treeAsset = AssetDatabase.LoadAssetAtPath <BehaviourTreeUI.TreeGraph>(treePath + "/" + fileName); if (treeAsset) { return(treeAsset); } else { return(GetNewTree(sourceTree)); } }