Ejemplo n.º 1
0
 public void HandleRemoveNode(NoFlo_Basic.Component component)
 {
     if (component.Visualisation != null)
     {
         Destroy(component.Visualisation.gameObject);
     }
 }
Ejemplo n.º 2
0
        private List <profile> BackwardConnectedNodes(NoFlo_Basic.Component n)
        {
            List <profile> list = new List <profile>();

            foreach (InPort p in n.Input.GetPorts())
            {
                foreach (Edge e in p.Edges())
                {
                    list.Add(profilesByNode[e.Source.Component]);
                }
            }
            return(list);
        }
Ejemplo n.º 3
0
        private List <profile> ForwardConnectedNodes(NoFlo_Basic.Component n)
        {
            List <profile> list = new List <profile>();

            foreach (OutPort p in n.Output.GetPorts())
            {
                foreach (Edge e in p.Edges())
                {
                    list.Add(profilesByNode[e.Target.Component]);
                }
            }
            return(list);
        }
Ejemplo n.º 4
0
        public void HandleAddNode(NoFlo_Basic.Component component)
        {
            GameObject newNode = Instantiate <GameObject>(Templates.NodeTemplate);

            newNode.transform.SetParent(GraphRenderingPanel);

            NodeVisualisation v = newNode.GetComponent <NodeVisualisation>();

            v.NodeName = component.ComponentName;
            v.Graph    = CurrentGraph;
            v.gameObject.GetComponentInChildren <ComponentNameVisualisation>().Component = component;
            component.Visualisation = v;
            v.SetupWithComponent(component);

            v.transform.localPosition = v.Component.MetadataPosition;
        }
        public void SetupWithComponent(NoFlo_Basic.Component component)
        {
            this.Component = component;

            SetName(component.ComponentName);
            ComponentQualifiedName.text = ComponentCatalog.RequestQualifedNameByComponentType()[component.GetType()];

            InPortVisualisations = new List <PortVisualisation>();
            foreach (NoFlo_Basic.InPort p in component.Input.GetPorts())
            {
                if (p.Hidden)
                {
                    continue;
                }

                GameObject        newPort = Instantiate <GameObject>(Graph.GraphEditor.Templates.PortTemplate);
                PortVisualisation v       = newPort.GetComponent <PortVisualisation>();
                InPortVisualisations.Add(v);
                newPort.transform.SetParent(InPortContainer);
                p.Visualisation = v;
                v.Port          = p;
                v.Graph         = Component.Graph;
            }

            OutPortVisualisations = new List <PortVisualisation>();
            foreach (NoFlo_Basic.OutPort p in component.Output.GetPorts())
            {
                if (p.Hidden)
                {
                    continue;
                }

                GameObject        newPort = Instantiate <GameObject>(Graph.GraphEditor.Templates.PortTemplate);
                PortVisualisation v       = newPort.GetComponent <PortVisualisation>();
                OutPortVisualisations.Add(v);
                newPort.transform.SetParent(OutPortContainer);
                p.Visualisation = v;
                v.Port          = p;
                v.Graph         = Component.Graph;
            }
        }
Ejemplo n.º 6
0
        public void SetNode(NoFlo_Basic.Component Component)
        {
            NormalMode();
            ComponentName.text = Component.ComponentName;

            foreach (Transform t in InPortsContainer)
            {
                Destroy(t.gameObject);
            }
            foreach (Transform t in OutPortsContainer)
            {
                Destroy(t.gameObject);
            }

            foreach (InPort p in Component.Input.GetPorts())
            {
                if (p.Hidden)
                {
                    continue;
                }

                PortInfo info = GameObject.Instantiate <GameObject>(InPortInfoTemplate).GetComponent <PortInfo>();
                info.transform.SetParent(InPortsContainer);
                info.Setup(p, this);
            }

            foreach (OutPort p in Component.Output.GetPorts())
            {
                if (p.Hidden)
                {
                    continue;
                }

                PortInfo info = GameObject.Instantiate <GameObject>(OutPortInfoTemplate).GetComponent <PortInfo>();
                info.transform.SetParent(OutPortsContainer);
                info.Setup(p, this);
            }

            NormalMode();
            LayoutRebuilder.ForceRebuildLayoutImmediate(transform as RectTransform);
        }
Ejemplo n.º 7
0
        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);
        }