public Component AddNode(string Name, Type ComponentType) { Component component = (Component)Activator.CreateInstance(ComponentType); NodesByName.Add(Name, component); component.SetName(Name); component.SetGraph(this); if (GraphEditor != null) { GraphEditor.EventOptions.NodeAdded.Invoke(component); } return(component); }
void Start() { Text = GetComponentInChildren <Text>(); Button = GetComponent <Button>(); Button.onClick.AddListener(Action); Dictionary <string, Type> ComponentsByQualifiedName = ComponentCatalog.RequestComponentsByQualifiedName(); foreach (string QualifiedName in ComponentsByQualifiedName.Keys) { ComponentSelection cs = GameObject.Instantiate <GameObject>(ComponentSelectionTemplate).GetComponent <ComponentSelection>(); cs.transform.SetParent(SideMenuContents); cs.Setup(QualifiedName, ComponentsByQualifiedName[QualifiedName], () => { SideMenu.SetActive(false); NoFlo_Basic.Component c = Graph.AddNode(cs.ComponentType); c.SetName(cs.ComponentType.Name); c.Visualisation.transform.position = Camera.main.ViewportToScreenPoint(0.5f * Vector2.one); Text.text = "Add"; }); } SideMenu.SetActive(false); }