示例#1
0
        public static ImNode Create(string file, JsonValue vl, bool ignoreId = false)
        {
            if (!vl.IsJsonObject)
            {
                return(null);
            }

            var type = vl["type"];

            if (!type.IsString)
            {
                return(null);
            }

            var node = ImNodeRegistry.Create(type.AsString);

            if (node == null)
            {
                Log.Error($"Unknown node type {type.AsString}");
                return(null);
            }

            node.Tip  = type.AsString;
            node.File = file;
            node.Load(vl);

            if (ignoreId)
            {
                node.Id = LastId;
            }

            ImNodes.Nodes[node.Id] = node;
            return(node);
        }
示例#2
0
 public virtual void Save(JsonObject root)
 {
     root["id"]      = Id;
     root["outputs"] = SaveConnections(Outputs);
     root["type"]    = ImNodeRegistry.GetName(this);
     root["x"]       = RealPosition.X;
     root["y"]       = RealPosition.Y;
 }