public async System.Threading.Tasks.Task ObjNodeTestAsync() { JSchemaGenerator generator = new JSchemaGenerator(); JSchema schema = generator.Generate(typeof(Account)); var node = new ObjectNode(); node.InPorts = new List <INode>(); node.LogicPath = true; node.Schema = schema.ToString(); var account = new Account { Email = "*****@*****.**", Name = "Johe Doe", Age = 20, DateBrith = new DateTimeOffset(1980, 1, 1, 12, 1, 2, new TimeSpan(-6, 0, 0)), Address = new Address { Line1 = "Mobile AL" }, Duration = new TimeSpan(12, 0, 1), LastLogin = DateTime.Now }; node.JsonString = JsonConvert.SerializeObject(account); await node.Init(new PadExecutionContext() { Pad = new Pad(Engine.Enums.ExecutionMode.Normal) { Nodes = new List <INode>() } }); await node.Execute(node.Context); Assert.NotNull(node.ObjectValue); }
public static ObjectNode Create(Rect NodeRect, NodeType nodeType = NodeType.Object) { // This function has to be registered in Node_Editor.ContextCallback ObjectNode node = ScriptableObject.CreateInstance <ObjectNode>(); node.nodeType = nodeType; node.baseObject = new GameObject(); node.crimeObject = node.baseObject.AddComponent <CrimeObject>(); node.rect = NodeRect; node.selects = new Dictionary <NodeOutput, Selection>(); if (nodeType == NodeType.Object) { node.crimeObject.isItem = false; node.baseObject.transform.localPosition = Vector3.zero; node.baseObject.transform.parent = GameObject.Find("CrimeObjects").transform; node.baseObject.name = "새 오브젝트"; node.baseObject.AddComponent <SpriteRenderer>(); node.name = "오브젝트"; NodeOutput.Create(node, "오브젝트 입력", IOtype.ObjectOnly); GameObject transHolder = new GameObject(); transHolder.name = "버튼 생성위치"; transHolder.transform.parent = node.baseObject.transform; node.crimeObject.buttonTrans = transHolder.transform; } else if (nodeType == NodeType.Item) { node.crimeObject.isItem = true; node.baseObject.transform.parent = GameObject.Find("CrimeItems").transform; node.baseObject.name = "새 아이템"; node.name = "아이템"; NodeOutput.Create(node, "아이템 입력", IOtype.ItemOnly); } else if (nodeType == NodeType.Route) { node.crimeObject.isItem = true; node.crimeObject.useAsRoute = true; node.baseObject.transform.parent = GameObject.Find("CrimeConditions").transform; node.baseObject.name = "새 조건식"; node.name = "조건"; NodeOutput.Create(node, "조건 입력", IOtype.General); } node.Init(); Node_Editor.editor.OnSave += node.OnSave; Node_Editor.editor.OnLoad += node.OnLoad; return(node); }