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); }
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); }
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(); }
public void RemoveEdge(DataGraphNode n, DataGraphNode v) { int index = nodes.IndexOf(n); if (index >= 0) { nodeChildren[index].list.Remove(v); } }
public void RemoveNode(DataGraphNode n) { int index = nodes.IndexOf(n); if (index >= 0) { nodeChildren.RemoveAt(index); nodes.Remove(n); } }
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 )); }
public List <DataGraphNode> GetNodeConnections(DataGraphNode n) { int index = nodes.IndexOf(n); if (index < 0) { return(null); } return(nodeChildren[index].list); }
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); }
public DialogueNode( Vector2 position, Action <ConnectionPoint> OnClickInPoint, Action <ConnectionPoint> OnClickOutPoint, Action <Node> OnClickRemoveNode, DataGraphNode newDataNode, DialogueNodeBasedEditor editor ) : base( position, OnClickInPoint, OnClickOutPoint, OnClickRemoveNode, newDataNode, editor ) { }
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); } }
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); }