mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-06-26 19:34:47 +00:00
34 lines
926 B
C#
34 lines
926 B
C#
|
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;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
}
|