public Node CreateNode(string typeID, Vector2 pos)
        {
            Undo.RecordObject(_nodeDataContainer, "Create Node");
            Node node = _nodeData.CreateNode(typeID);

            node.Position = pos;
            DefaultNode.InitDefaults(node, _nodeData);
            RebuildGraph();
            return(node);
        }
Пример #2
0
        public static void Deserialize(string data, NodeData nodeData, Dictionary <int, Node> nodes)
        {
            nodes.Clear();
            string[] nodeStrings = data.Split('#');
            if (nodeStrings.Length < 2)
            {
                return;
            }
            for (int n = 0; n < nodeStrings.Length; n++)
            {
                string[] lines = nodeStrings[n].Split('|');

                Node node = nodeData.CreateNode(lines[0], int.Parse(lines[1]));
                if (node == null)
                {
                    continue;
                }
                ICustomSerialiser custom = node as ICustomSerialiser;
                if (custom != null)
                {
                    custom.Deserialize(lines);
                    continue;
                }

                node.Position = StringToPosition(lines[2]);

                FillInputs(ref node.Inputs, lines[3]);

                FieldInfo[] fields = node.GetType().GetFields(BindingFlags.Public | BindingFlags.Instance);
                for (int i = 0, l = 4; i < fields.Length; i++)
                {
                    if ((fields[i].Attributes & FieldAttributes.NotSerialized) != 0)
                    {
                        continue;
                    }
                    if (Exeptions.Contains(fields[i].Name))
                    {
                        continue;
                    }

                    DeserializeField(fields[i], node, lines[l++]);
                }
            }
        }