protected virtual void DrawWindow(int windowId) { Block block = windowBlockMap[windowId]; Flowchart flowchart = block.GetFlowchart(); // Select block when node is clicked if (Event.current.button == 0 && Event.current.type == EventType.MouseDown && !mouseOverVariables) { // Check if might be start of a window drag if (Event.current.button == 0 && Event.current.alt == false) { dragWindowId = windowId; startDragPosition.x = block.nodeRect.x; startDragPosition.y = block.nodeRect.y; } if (windowId < windowBlockMap.Count) { Undo.RecordObject(flowchart, "Select"); SelectBlock(flowchart, block); GUIUtility.keyboardControl = 0; // Fix for textarea not refeshing (change focus) } } bool selected = (flowchart.selectedBlock == block); GUIStyle nodeStyleCopy = new GUIStyle(nodeStyle); if (block.eventHandler != null) { nodeStyleCopy.normal.background = selected ? FungusEditorResources.texEventNodeOn : FungusEditorResources.texEventNodeOff; } else { // Count the number of unique connections (excluding self references) List <Block> uniqueList = new List <Block>(); List <Block> connectedBlocks = block.GetConnectedBlocks(); foreach (Block connectedBlock in connectedBlocks) { if (connectedBlock == block || uniqueList.Contains(connectedBlock)) { continue; } uniqueList.Add(connectedBlock); } if (uniqueList.Count > 1) { nodeStyleCopy.normal.background = selected ? FungusEditorResources.texChoiceNodeOn : FungusEditorResources.texChoiceNodeOff; } else { nodeStyleCopy.normal.background = selected ? FungusEditorResources.texProcessNodeOn : FungusEditorResources.texProcessNodeOff; } } nodeStyleCopy.normal.textColor = Color.black; // Make sure node is wide enough to fit the node name text float width = nodeStyleCopy.CalcSize(new GUIContent(block.blockName)).x; block.nodeRect.width = Mathf.Max(block.nodeRect.width, width); GUI.backgroundColor = Color.white; GUILayout.Box(block.blockName, nodeStyleCopy, GUILayout.Width(block.nodeRect.width), GUILayout.Height(block.nodeRect.height)); if (block.eventHandler != null) { string handlerLabel = ""; EventHandlerInfoAttribute info = EventHandlerEditor.GetEventHandlerInfo(block.eventHandler.GetType()); if (info != null) { handlerLabel = "<" + info.EventHandlerName + "> "; } string handlerSummary = block.eventHandler.GetSummary(); if (handlerSummary.Length > 0) { handlerLabel += handlerSummary; } GUIStyle handlerStyle = new GUIStyle(EditorStyles.helpBox); handlerStyle.wordWrap = true; handlerStyle.margin.top = 0; handlerStyle.margin.bottom = 0; GUILayout.Label(handlerLabel, handlerStyle); // Move connection marker down below handler description float height = 44 + handlerStyle.CalcHeight(new GUIContent(handlerLabel), block.nodeRect.width); block.nodeRect.height = height; } if (block.description.Length > 0) { GUIStyle descriptionStyle = new GUIStyle(EditorStyles.whiteLabel); descriptionStyle.wordWrap = true; GUILayout.Label(block.description, descriptionStyle); } if (Event.current.type == EventType.ContextClick) { GenericMenu menu = new GenericMenu(); menu.AddItem(new GUIContent("Duplicate"), false, DuplicateBlock, block); menu.AddItem(new GUIContent("Delete"), false, DeleteBlock, block); menu.ShowAsContext(); } }