public void EmitConnectionEvent(OnConnectionEvent e) { switch (modifyMode) { case ModifyMode.CONNECT_ENDED: { switch (e.eventType) { case OnConnectionEvent.EventType.EVENT_CONNECTION_TAPPED: { var tappedConnectionId = e.eventSourceCon.connectionId; foreach (var con in connections) { if (con.connectionId == tappedConnectionId) { con.SetActive(); activeObject = new ActiveObject(AssetGraphSettings.ObjectKind.CONNECTION, con.connectionId, Vector2.zero); } else { con.SetInactive(); } } // set deactive for all nodes. foreach (var node in nodes) { node.SetInactive(); } break; } case OnConnectionEvent.EventType.EVENT_CONNECTION_DELETED: { Undo.RecordObject(this, "Delete Connection"); var deletedConnectionId = e.eventSourceCon.connectionId; DeleteConnectionById(deletedConnectionId); SaveGraphWithReload(); Repaint(); break; } default: { // Debug.Log("unconsumed or ignored event:" + e.eventType); break; } } break; } } }
public void EmitConnectionEvent (OnConnectionEvent e) { switch (modifyMode) { case ModifyMode.CONNECT_ENDED: { switch (e.eventType) { case OnConnectionEvent.EventType.EVENT_CONNECTION_TAPPED: { if (Event.current.shift) { Undo.RecordObject(this, "Select Objects"); var objectId = string.Empty; if (e.eventSourceCon != null) { objectId = e.eventSourceCon.connectionId; if (!activeObject.idPosDict.ReadonlyDict().Any()) { activeObject = RenewActiveObject(new List<string>{objectId}); } else { var additiveIds = new List<string>(activeObject.idPosDict.ReadonlyDict().Keys); // already contained, cancel. if (additiveIds.Contains(objectId)) { additiveIds.Remove(objectId); } else { additiveIds.Add(objectId); } activeObject = RenewActiveObject(additiveIds); } } UpdateActivationOfObjects(activeObject); break; } Undo.RecordObject(this, "Select Connection"); var tappedConnectionId = e.eventSourceCon.connectionId; foreach (var con in connections) { if (con.connectionId == tappedConnectionId) { con.SetActive(); activeObject = RenewActiveObject(new List<string>{con.connectionId}); } else { con.SetInactive(); } } // set deactive for all nodes. foreach (var node in nodes) { node.SetInactive(); } break; } case OnConnectionEvent.EventType.EVENT_CONNECTION_DELETED: { Undo.RecordObject(this, "Delete Connection"); var deletedConnectionId = e.eventSourceCon.connectionId; DeleteConnectionById(deletedConnectionId); SaveGraphWithReload(); Repaint(); break; } default: { // Debug.Log("unconsumed or ignored event:" + e.eventType); break; } } break; } } }