mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-11-12 00:58:16 +00:00
提交确定性AI案例
This commit is contained in:
@@ -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()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user