public void OnBeginDrag(PointerEventData eventData) { if (port.IsOutput) { tempConnection = Instantiate(graph.runtimeConnectionPrefab); tempConnection.transform.SetParent(graph.scrollRect.content); tempConnection.SetPosition(transform.position, eventData.position); startPos = transform.position; startPort = port; } else { if (port.IsConnected) { NodePort output = port.Connection; Debug.Log("has " + port.ConnectionCount + " connections"); Debug.Log(port.GetConnection(0)); UGUIMathBaseNode otherNode = graph.GetRuntimeNode(output.node); UGUIPort otherUGUIPort = otherNode.GetPort(output.fieldName); Debug.Log("Disconnect"); output.Disconnect(port); tempConnection = Instantiate(graph.runtimeConnectionPrefab); tempConnection.transform.SetParent(graph.scrollRect.content); tempConnection.SetPosition(otherUGUIPort.transform.position, eventData.position); startPos = otherUGUIPort.transform.position; startPort = otherUGUIPort.port; graph.GetRuntimeNode(node).UpdateGUI(); } } }
public void UpdateConnectionTransforms() { if (port.IsInput) { return; } while (connections.Count < port.ConnectionCount) { AddConnection(); } while (connections.Count > port.ConnectionCount) { Destroy(connections[0].gameObject); connections.RemoveAt(0); } // Loop through connections for (int i = 0; i < port.ConnectionCount; i++) { NodePort other = port.GetConnection(i); UGUIMathBaseNode otherNode = graph.GetRuntimeNode(other.node); if (!otherNode) { Debug.LogWarning(other.node.name + " node not found", this); } Transform port2 = otherNode.GetPort(other.fieldName).transform; if (!port2) { Debug.LogWarning(other.fieldName + " not found", this); } connections[i].SetPosition(transform.position, port2.position); } }