Esempio n. 1
0
        //Create Data from Object
        public static NodeGraphData CreateData(NodeGraph graph)
        {
            NodeGraphData graphData = new NodeGraphData();
            graphData.Name = graph.Name;
            graphData.scrollPos = graph.scrollPos;

            for (int i = 0; i < graph.nodes.Count; i++)
            {
                NodeData nData = new NodeData();
                nData.NodeType = graph.nodes[i].GetNodeType;
                nData.NodeID = graph.nodes[i].ID;
                nData.properties.CopyPropertiesDataFrom(graph.nodes[i].properties);
                nData.NodePos = new Vector2(graph.nodes[i].rect.x, graph.nodes[i].rect.y);

                var connections = graph.nodes[i].GetAllConnections();
                for (int n = 0; n < connections.Length; n++)
                {
                    ConnectionData cData = new ConnectionData();
                    cData.OutNodeID = connections[n].startSocket.parentNode.ID;
                    cData.OutNodeSocketID = connections[n].startSocket.ID;
                    cData.InNodeID = connections[n].endSocket.parentNode.ID;
                    cData.InNodeSocketID = connections[n].endSocket.ID;

                    if (graphData.connections != null)
                    {
                        int index = graphData.connections.FindIndex(item => item.ID == cData.ID);
                        if (index == -1)
                            graphData.connections.Add(cData);
                    }
                }

                graphData.nodes.Add(nData);
            }

            return graphData;
        }
Esempio n. 2
0
        private static Socket GetSocket(NodeGraph graph, string nodeID, int socketID)
        {
            for (int i = 0; i < graph.nodes.Count; i++)
            {
                if (graph.nodes[i].ID == nodeID)
                {
                    var sockets = graph.nodes[i].GetAllSockets();
                    for (int n = 0; n < sockets.Length; n++)
                    {
                        if (sockets[n].ID == socketID)
                            return sockets[n];
                    }
                }
            }

            return null;
        }
Esempio n. 3
0
 void Graph_PostLoad(NodeGraph graph, NodeGraphData graphData)
 {
     GraphPostLoaded.InvokeSafe();
 }
Esempio n. 4
0
 void Graph_PostUnload(NodeGraph graph)
 {
     GraphPostUnloaded.InvokeSafe();
 }
Esempio n. 5
0
 void Graph_Saved(NodeGraph graph)
 {
     NodeEditor.Logger.Log <NodeGraphState>("Graph was saved.");
     IsDirty = false;
     Changed.InvokeSafe(this);
 }
Esempio n. 6
0
        public static bool UpdateInput(NodeGraph Graph)
        {
            bool changed = false;

            //return UpdateHovering(mousePos, Graph.nodes);

            //changed = UpdateSelecting(mousePos, Graph.nodes);

            return changed;
        }