public static void WellFormatedNewNodeWithPositionAndDataCommand() { string s = BaseGraphCLI.GenerateNewNodeCommand(typeof(NodePerlinNoise2D), "perlin noise", new Vector2(21, 84), new BaseGraphCLIAttributes { { "persistence", 1.4f }, { "octaves", 2 } }); BaseGraphCommand cmd = BaseGraphCLI.Parse(s); var parsedAttrs = Jsonizer.Parse(cmd.attributes); var persistenceAttr = parsedAttrs[0]; var octavesAttr = parsedAttrs[1]; Assert.That(persistenceAttr.first == "persistence", "The persistence name expected to be 'persistence' but was '" + persistenceAttr.first + "'"); Assert.That((float)persistenceAttr.second == 1.4f, "The persistence value expected to be 1.4 but was '" + persistenceAttr.second + "'"); Assert.That(octavesAttr.first == "octaves", "The octaves name expected to be 'octaves' but was '" + octavesAttr.first + "'"); Assert.That((int)octavesAttr.second == 2, "The octaves value expected to be 2 but was '" + octavesAttr.second + "'"); }
static void CreateNode(BaseGraph graph, BaseGraphCommand command, string inputCommand) { Vector2 position = command.position; BaseNode node = null; //if we receive a CreateNode with input/output graph nodes, we assign them so we don't have multiple inout/output nodes if (NodeTypeProvider.inputGraphTypes.Contains(command.nodeType)) { node = graph.inputNode; } else if (NodeTypeProvider.outputGraphTypes.Contains(command.nodeType)) { node = graph.outputNode; } else { node = graph.CreateNewNode(command.nodeType, position); } //set the position again for input/output nodes node.rect.position = position; Type nodeType = node.GetType(); if (!String.IsNullOrEmpty(command.attributes)) { foreach (var attr in Jsonizer.Parse(command.attributes)) { FieldInfo attrField = nodeType.GetField(attr.first, BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly); if (attrField != null) { attrField.SetValue(node, attr.second); } else { Debug.LogError("Attribute " + attr.first + " can be found in node " + node); } } } node.name = command.name; }
private ContentSelectFieldOptionsHandlerParam ParseParam(string handlerParam) { return(Jsonizer.Parse <ContentSelectFieldOptionsHandlerParam>(handlerParam)); }
private DatumSelectFieldOptionsHandlerParam ParseParam(string handlerParam) { return(Jsonizer.Parse <DatumSelectFieldOptionsHandlerParam>(handlerParam)); }