提交确定性AI案例

This commit is contained in:
DESKTOP-5RP3AKU\Jisol
2024-11-15 19:21:14 +08:00
parent ae81ee6c84
commit a0a8751aa5
47 changed files with 18242 additions and 4024 deletions

View File

@@ -339,6 +339,12 @@ namespace BehaviorTreeSlayerEditor
GUI.Label(lbRect, Msg);
GUI.BeginGroup(systemRect, "", "box");
int topBtnWidth = 0;
if (GUI.Button(new Rect(topBtnWidth, 0, 120, 30), "Load", TopBtnStyle))
{
LoadFromFile(); // 调用读取文件的方法
}
topBtnWidth += 135;
if (GUI.Button(new Rect(topBtnWidth, 0, 120, 30), "Save", TopBtnStyle))
{
Save();
@@ -393,6 +399,22 @@ namespace BehaviorTreeSlayerEditor
this.Repaint();
}
}
private void LoadFromFile()
{
string path = EditorUtility.OpenFilePanel("Load Behavior Config", "", "txt");
if (!string.IsNullOrEmpty(path))
{
// 获取相对路径
string relativePath = "Assets" + path.Substring(Application.dataPath.Length);
// 使用 AssetDatabase 加载 TextAsset
TextAsset textAsset = AssetDatabase.LoadAssetAtPath<TextAsset>(relativePath);
BTreeManager.Ins.Init(textAsset.text);
treeConfig = textAsset;
TryOpen();
Msg = "Loaded from " + path;
}
}
private void Save()
{