public void OnEndDrag(PointerEventData eventData) { if (draggingLine == null) { return; } RRCSManager.Instance.selectionManager.SelectionEnabled = true; PortUi dstPort = null; foreach (GameObject go in eventData.hovered) { dstPort = go.GetComponent <PortUi>(); if (dstPort != null) { break; } } PortUi srcPort = draggingLine.sourcePortUi ?? this; draggingLine.Disconnect(); draggingLine = null; if (dstPort != null && (dstPort.nodeUi == null || !dstPort.nodeUi.IsSidebarNode)) { srcPort.port.Connect(dstPort.port); } }
public void OnBeginDrag(PointerEventData eventData) { if (eventData.button != 0) { return; } if (draggingLine != null) { return; } if (nodeUi && nodeUi.IsSidebarNode) { return; } PortUi srcPort = this; if (isInput && HasLines) { //connectedLines should contain exactly 1 entry. ConnectionUi entry = connectedLines[0]; entry.Disconnect(); srcPort = entry.sourcePortUi; } draggingLine = Instantiate(connectionPrefab, linesContainer).GetComponent <ConnectionUi>(); DebugUtils.Assert(draggingLine != null); draggingLine.sourcePortUi = srcPort; draggingLine.SetVirtualTargetPosition(Center); draggingLine.UpdateColors(); RRCSManager.Instance.selectionManager.SelectionEnabled = false; }
public static void Unregister(ConnectionUi connectionUi) { if (connectionUi.Connection != null) { connections.Remove(connectionUi.Connection); } }
private static void Port_Connected(Connection connection) { PortUi sourceUi = GetUi(connection.SourcePort); PortUi targetUi = GetUi(connection.TargetPort); ConnectionUi connectionUi = sourceUi.AddConnection(sourceUi, targetUi, connection, null); targetUi.AddConnection(sourceUi, targetUi, connection, connectionUi); }
public static void Register(ConnectionUi connectionUi) { DebugUtils.Assert(!connections.ContainsKey(connectionUi.Connection)); if (connections.ContainsKey(connectionUi.Connection)) { return; } connections[connectionUi.Connection] = connectionUi; }
internal bool RemoveConnection(ConnectionUi connection, bool destroyLine) { connectedLines.Remove(connection); if (connection != null) { if (destroyLine) { Destroy(connection.gameObject); return(false); } return(true); } return(true); }
internal ConnectionUi AddConnection(PortUi sourceUi, PortUi targetUi, Connection connection, ConnectionUi connectionUi) { if (connectionUi == null) { connectionUi = Instantiate(connectionPrefab, linesContainer).GetComponent <ConnectionUi>(); connectionUi.sourcePortUi = sourceUi; connectionUi.targetPortUi = targetUi; connectionUi.Connection = connection; } connectedLines.Add(connectionUi); connectionUi.UpdatePositions(); connectionUi.UpdateColors(); return(connectionUi); }