34 lines
926 B
C#
Raw Permalink Normal View History

2024-08-17 14:12:46 +08:00
namespace BehaviorTreeSlayer
{
public class Entry : Sequence
{
public string Serielize(TreeNode node)
{
string s = UnityEngine.JsonUtility.ToJson(node);
if (node is ComponentNode)
{
ComponentNode cp = node as ComponentNode;
int count = cp.childs.Count;
if (count > 0)
{
string c = "\"childs\":[";
for (int i = 0; i < count; i++)
{
c += Serielize(cp.childs[i]);
if (i < count - 1)
{
c += ",";
}
}
c += "],";
int idx = s.IndexOf("Sid");
s = s.Insert(idx - 1, c);
}
}
return s;
}
}
}