public void DeselectEntity() { if (!IsEntitySelected()) { return; } selectedEntity.GetWindow().Deselect(); selectedEntity = null; }
public void SelectEntity(GraphEntityData entityData) { if (IsEntitySelected() && selectedEntity != entityData) { selectedEntity.GetWindow().Deselect(); } selectedEntity = entityData; CreateBranchEditorWindow(); branchEditor.LoadBranch(selectedEntity); script.lastSelectedNode = branchEntityDatas.IndexOf(selectedEntity); }
private void CreateNewConnectionPointContextMenu(GraphEntityData graphEntity, ConnectionPoint connectedTo) { ConnectionPointDirection direction = connectedTo.connectionDirection == ConnectionPointDirection.In ? ConnectionPointDirection.Out : ConnectionPointDirection.In; string msg = "Add new " + (direction == ConnectionPointDirection.In ? "Input" : "Output") + " Connection Point of type " + connectedTo.connection.type + "?"; var genericMenu = new GenericMenu(); genericMenu.AddItem(new GUIContent(msg), false, () => CreateNewConnectionPointFromConnection(graphEntity, connectedTo, direction)); genericMenu.ShowAsContext(); }
public void LoadBranch(GraphEntityData branchData) { this.entityData = branchData; if (branchData is EventBranchObjectData) { gateway = null; var serializedBranch = (ScenimaticSerializedNode) ((EventBranchObjectData)branchData).serializedNode; branch = serializedBranch.data; } else { branch = null; var serializedGateway = ((ScriptGatewayNodeData)branchData).serializedNode; gateway = serializedGateway.data; } Repaint(); }
private void CreateNewConnectionPointFromConnection(GraphEntityData graphEntity, ConnectionPoint connectedTo, ConnectionPointDirection direction) { Connection newConn = new Connection() { type = connectedTo.connection.type, GUID = System.Guid.NewGuid().ToString(), variableName = connectedTo.connection.variableName, }; ScenimaticBranchEditor.CheckForDuplicateNameInConnections(newConn, graphEntity.GetConnections(direction)); graphEntity.AddNewConnectionPoint(newConn, direction); if (!connectedTo.AllowsMultipleConnections()) { connectedTo.RemoveAllConnections(); } newConn.connectedToGUIDs.Add(connectedTo.GUID); connectedTo.connection.connectedToGUIDs.Add(newConn.GUID); RefreshConnectionPoint(connectedTo); }
public void MouseOver(GraphEntityData graphEntityData) { // Left mouse up over this entity if (startConnection == null) { return; } if (startConnection.data.type != ConnectionType.ControlFlow && graphEntityData != startConnection.nodeWindow.entityData) { ScriptGatewayNodeData gatewayData = graphEntityData as ScriptGatewayNodeData; ScriptGatewayNodeData connGatewayData = startConnection.nodeWindow.entityData as ScriptGatewayNodeData; if (gatewayData == null && connGatewayData == null) { if (startConnection.connectionDirection == ConnectionPointDirection.Out) { CreateNewConnectionPointContextMenu(graphEntityData, startConnection); } } else { if ((connGatewayData != null && (connGatewayData.serializedNode.data.gatewayType == GatewayType.Entrance || gatewayData != null)) || (gatewayData != null && gatewayData.serializedNode.data.gatewayType == GatewayType.Entrance) || (gatewayData != null && gatewayData.serializedNode.data.gatewayType == GatewayType.Exit && startConnection.connectionDirection != ConnectionPointDirection.In)) { CreateNewConnectionPointContextMenu(graphEntityData, startConnection); } } } startConnection.isCreatingNewConnection = false; startConnection = null; }
public void DeleteEntity(GraphEntityData entityData) { // warn if branch has connections ScenimaticSerializedNode serializedEntity = null; foreach (var branch in script.branches) { if (branch.GUID == entityData.GUID) { serializedEntity = branch; break; } } if (serializedEntity == null) { Debug.LogError("Entity Deletion Error: Entity " + entityData.GUID + " could not be found in script"); return; } bool confirmed = false; foreach (var conn in serializedEntity.data.connectionInputs) { // check if anything still connected so we can warn the user if (IsConnected(conn)) { // show warning if (!confirmed && !EditorUtility.DisplayDialog("Delete this Branch?", "This branch has connections to other branches." + " If you continue, connections will be lost." + "\nAre you sure?", "Yes", "No")) { return; } confirmed = true; Disconnect(conn); } } foreach (var conn in serializedEntity.data.connectionOutputs) { // check if anything still connected so we can warn the user if (IsConnected(conn)) { // show warning if (!confirmed && !EditorUtility.DisplayDialog("Delete this Branch?", "This branch has connections to other branches." + " If you continue, connections will be lost." + "\nAre you sure?", "Yes", "No")) { return; } confirmed = true; Disconnect(conn); } } // check if this is the selected branch and switch branched if it is if (IsEntitySelected() && selectedEntity != entityData) { selectedEntity.GetWindow().Deselect(); } // delete branchEntityDatas.Remove(entityData); script.branches.Remove(serializedEntity); }