示例#1
0
    public Node(
        Vector2 position,
        Action <ConnectionPoint> OnClickInPoint,
        Action <ConnectionPoint> OnClickOutPoint,
        Action <Node> OnClickRemoveNode,
        DataGraphNode newDataNode,
        NodeBasedEditor editor
        )
    {
        dataNode      = newDataNode;
        currentEditor = editor;

        SetStyles();
        UpdateSize();

        rect         = new Rect(position.x, position.y, width, height);
        inPoint      = new ConnectionPoint(this, ConnectionPointType.In, OnClickInPoint);
        outPoint     = new ConnectionPoint(this, ConnectionPointType.Out, OnClickOutPoint);
        OnRemoveNode = OnClickRemoveNode;

        if (dataNode.uiSettings != null)
        {
            rect = dataNode.uiSettings.rect;
        }
        else
        {
            dataNode.SetUIRect(rect);
        }

        inspector = Editor.CreateEditor(dataNode);
    }
示例#2
0
    public bool AddEdge(DataGraphNode n, DataGraphNode v)
    {
        int nIndex = nodes.IndexOf(n);

        if (nIndex < 0)
        {
            nIndex = AddNode(n);
        }

        if (!nodes.Contains(v))
        {
            AddNode(v);
        }

        if (nIndex < 0)
        {
            return(false);
        }

        if (!nodeChildren[nIndex].list.Contains(v))
        {
            nodeChildren[nIndex].list.Add(v);
        }

        return(true);
    }
示例#3
0
    protected virtual Node OnClickAddNode(Vector2 mousePosition, DataGraphNode dataNode = null)
    {
        if (data == null)
        {
            return(null);
        }

        if (nodes == null)
        {
            nodes = new List <Node>();
        }

        DataGraphNode dataGraphNode = dataNode != null ? dataNode : OnCreateDataNode();

        if (dataGraphNode != null)
        {
            Node newNode = BindNode(mousePosition, dataGraphNode);

            if (newNode.IsNodeAllowed(true))
            {
                nodes.Add(newNode);
                return(newNode);
            }
        }

        return(null);
    }
    protected virtual void OnRemoveDataNode(DataGraphNode node)
    {
        dataGraph.RemoveNode(node);
        DestroyImmediate(node, true);

        OnNodeEditorDataChange();
    }
示例#5
0
    public void RemoveEdge(DataGraphNode n, DataGraphNode v)
    {
        int index = nodes.IndexOf(n);

        if (index >= 0)
        {
            nodeChildren[index].list.Remove(v);
        }
    }
示例#6
0
    public void RemoveNode(DataGraphNode n)
    {
        int index = nodes.IndexOf(n);

        if (index >= 0)
        {
            nodeChildren.RemoveAt(index);
            nodes.Remove(n);
        }
    }
示例#7
0
 protected virtual Node BindNode(Vector2 mousePosition, DataGraphNode dataGraphNode)
 {
     return(new Node(
                mousePosition,
                OnClickInPoint,
                OnClickOutPoint,
                OnClickRemoveNode,
                dataGraphNode,
                this
                ));
 }
 protected override Node BindNode(Vector2 mousePosition, DataGraphNode dataGraphNode)
 {
     return(new DialogueNode(
                mousePosition,
                OnClickInPoint,
                OnClickOutPoint,
                OnClickRemoveNode,
                dataGraphNode,
                this
                ));
 }
示例#9
0
    public List <DataGraphNode> GetNodeConnections(DataGraphNode n)
    {
        int index = nodes.IndexOf(n);

        if (index < 0)
        {
            return(null);
        }


        return(nodeChildren[index].list);
    }
示例#10
0
    protected virtual DataGraphNode OnCreateDataNode()
    {
        DataGraphNode newNode = CreateInstance <DataGraphNode>();

        AssetDatabase.AddObjectToAsset(newNode, assetPath + Path.DirectorySeparatorChar + dataGraph.name + ".asset");

        newNode.uiSettings = null;

        dataGraph.AddNode(newNode);
        OnNodeEditorDataChange();

        Debug.Log(newNode.uiSettings);

        return(newNode);
    }
示例#11
0
 public DialogueNode(
     Vector2 position,
     Action <ConnectionPoint> OnClickInPoint,
     Action <ConnectionPoint> OnClickOutPoint,
     Action <Node> OnClickRemoveNode,
     DataGraphNode newDataNode,
     DialogueNodeBasedEditor editor
     ) : base(
         position,
         OnClickInPoint,
         OnClickOutPoint,
         OnClickRemoveNode,
         newDataNode,
         editor
         )
 {
 }
示例#12
0
    public virtual int AddNode(DataGraphNode n)
    {
        int index = nodes.IndexOf(n);

        if (index < 0)
        {
            nodes.Add(n);
            nodeChildren.Add(new DataGraphNodeConnection());

            Debug.Assert(nodes.Count == nodeChildren.Count);

            return(nodes.Count - 1);
        }
        else
        {
            return(-1);
        }
    }
示例#13
0
    protected override DataGraphNode OnCreateDataNode()
    {
        DataGraphNode newNode = CreateInstance <DialogueDataNode>();

        AssetDatabase.AddObjectToAsset(newNode, assetPath + Path.DirectorySeparatorChar + dataGraph.name + ".asset");

        newNode.uiSettings = null;

        int result = dataGraph.AddNode(newNode);

        if (result >= 0)
        {
            OnNodeEditorDataChange();
            return(newNode);
        }

        return(null);
    }