public virtual FunctionGraphEditorNodeSerializable CreateSerializeable()
    {
        FunctionGraphEditorNodeSerializable ser = new FunctionGraphEditorNodeSerializable();

        ser.EditorNodeType = GetType().ToString();
        ser.NodePosition   = Rect.position;
        ser.NodeValue      = "";
        ser.GraphNodeType  = GraphNode.GetType().ToString();


        if (GraphNode.HasParent)
        {
            var parent = Editor.GetNode(GraphNode.Parent);
            ser.ParentIndex = Editor.GetListIndexOf(parent);
            ser.ToIdx       = conToDraw.EditorNodeConnectionPointIndex;
            ser.FromIdx     = connectionPoints.IndexOf(conToDraw.fromPoint);
        }
        else
        {
            ser.ParentIndex = -1;
            ser.ToIdx       = ser.FromIdx = -1;
            ser.FromIdx     = -1;
        }

        return(ser);
    }
Example #2
0
    private void DeserializeNodeData(FunctionGraphEditorNodeSerializable data, List <NodeNeedingParenting> needParenting)
    {
        BaseFuncGraphNode n = FuncGraphNodeFactory.CreateNode(Type.GetType($"{data.GraphNodeType}, {Assembly.GetAssembly(typeof(BaseFuncGraphNode)).FullName}"), graph);

        CreateNode(data.NodePosition, n);

        var newNode = nodesList[nodesList.Count - 1];

        //if (data.fromIDX >= 0 && data.toIdx >= 0)
        //{
        //    //Debug.Log("Creating Node Connection from editor ");
        //    recentChild.CreateConnection(nodeParent, nodeParent.GetConnectionPoint(data.toIdx).Idx, recentChild.GetConnectionPoint(data.fromIDX), nodeParent.GetConnectionPoint(data.toIdx));
        //}
        newNode.DeserializeData(data.NodeValue);
        if (data.ParentIndex >= 0)
        {
            needParenting.Add(new NodeNeedingParenting(data, newNode));
        }
    }
Example #3
0
 public NodeNeedingParenting(FunctionGraphEditorNodeSerializable data, FunctionGraphEditorNode node)
 {
     this.Data = data;
     this.Node = node ?? throw new ArgumentNullException(nameof(node));
 }