public static NodeProto ConfigToNode(BehaviorNodeConfig nodeProto) { NodeProto nodeData = new NodeProto(); nodeData.Id = nodeProto.id; nodeData.Name = nodeProto.name; nodeData.Desc = nodeProto.describe; nodeData.Args = nodeProto.GetArgsDict(); nodeData.children = new List <NodeProto>(); foreach (Transform child in nodeProto.gameObject.transform) { BehaviorNodeConfig nodeConfig = child.gameObject.GetComponent <BehaviorNodeConfig>(); NodeProto childData = ConfigToNode(nodeConfig); nodeData.children.Add(childData); } return(nodeData); }
private static NodeProto BehaviorNodeConfigToNodeProto(BehaviorNodeConfig behaviorNodeConfig) { NodeProto nodeProto = new NodeProto { Id = behaviorNodeConfig.id, Name = behaviorNodeConfig.name, Desc = behaviorNodeConfig.describe, Args = behaviorNodeConfig.GetArgsDict(), children = new List <NodeProto>() }; foreach (Transform child in behaviorNodeConfig.gameObject.transform) { BehaviorNodeConfig nodeConfig = child.gameObject.GetComponent <BehaviorNodeConfig>(); NodeProto childData = BehaviorNodeConfigToNodeProto(nodeConfig); nodeProto.children.Add(childData); } return(nodeProto); }