private AITreeNode ConstructTree(NodeEditorNode node, Dictionary <AITreeNode, NodeEditorNode> resultDictionary) { if (node.data is MethodBinding methodBinding) { AITreeNode output = new AITreeNode( methodBinding, node.GUID, node.GetChildren().Select(x => ConstructTree(x, resultDictionary)).ToArray());; resultDictionary[output] = node; return(output); } return(null); }
protected override void OnSave(string filename) { string filenameWithoutExtension = Path.GetFileNameWithoutExtension(filename); string dirName = Path.GetDirectoryName(filename); foreach (var node in save.Nodes) { if (node.data is AITreeDefinition def) { AITreeNode treeNode = ConstructorTreeFromDef(node); string treePath = $"{dirName}/{filenameWithoutExtension}.{def.name}.asset"; AITreeAsset aITreeAsset = CreateInstance <AITreeAsset>(); aITreeAsset.root = treeNode; aITreeAsset.sourceFileName = filename; aITreeAsset.definition = def; AssetManagement.CreateOrOverwriteAsset(treePath, aITreeAsset); } } }
private void DrawAINodeEntry(AITreeNode node, Dictionary <AITreeNode, NodeEditorNode> treeToEditorNodeMap, int indentLevel) { if (node == null) { return; } GUILayout.BeginHorizontal(); { GUILayout.Space(10 * indentLevel); if (GUILayout.Button(node.methodBinding.ToString())) { JumpCameraToNode(treeToEditorNodeMap[node]); } } GUILayout.EndHorizontal(); foreach (var child in node.children) { DrawAINodeEntry(child, treeToEditorNodeMap, indentLevel + 1); } }