private object ValueOfInput(NodeParameter nodeParameter) { //get the first property var nodeChain = NodeChain; var inputNodeId = nodeParameter.InputNodeId.ID; var inputNode = nodeChain.Nodes.FirstOrDefault(n => n.ID == inputNodeId) as PropertyNode; var input = inputNode.EvaluateInput(nodeChain, o => o); return(input); }
public SubNodeParameter() { Parameter = null; }
protected NodeParameter Add(string name, PropertyType propertyType, object property, object defaultValue, PropertySource source = PropertySource.EnteredOnly, PropertyFamily familyType = PropertyFamily.Primitive) { NodeParameter exists; Parameters.TryGetValue(name, out exists); if (exists != null) { if (exists.PropertyType == PropertyType.Enum) { if (!(exists.Property is Type)) { var paramType = Type.GetType((string)exists.Property); if (paramType != null) { exists.Value = Enum.ToObject(paramType, Convert.ToInt32(exists.Value)); } } } else if (exists.PropertyType == PropertyType.Int) { exists.Value = Convert.ToInt32(exists.Value); } else if (exists.PropertyType == PropertyType.Float) { exists.Value = Convert.ToSingle(exists.Value); } else if (exists.PropertyType == PropertyType.GameObject) { exists.Value = Convert.ToString(exists.Value); } else if (exists.PropertyType == PropertyType.StringArray) { var s = exists.Property as JArray; exists.Property = (s == null ? exists.Property : s.ToObject <string[]>()); exists.Value = Convert.ToInt32(exists.Value); } else if (exists.PropertyType == PropertyType.IntArray) { var s = exists.Property as JArray; exists.Property = (s == null ? exists.Property : s.ToObject <int[]>()); exists.Value = Convert.ToInt32(exists.Value); } return(exists); } var newParam = new NodeParameter() { Name = name, PropertyType = propertyType, Property = property, Value = defaultValue, SubParams = new Dictionary <string, SubNodeParameter>(), Source = source, PropertyFamily = familyType }; Parameters.Add(newParam.Name, newParam); return(newParam); }