//--------------------------------- // Constructor //--------------------------------- public UISpeechNode(EditableConversationNode infoNode, Vector2 pos) : base(infoNode, pos) { if (defaultNodeStyle == null || defaultNodeStyle.normal.background == null) { defaultNodeStyle = new GUIStyle(); defaultNodeStyle.normal.background = DialogueEditorUtil.MakeTextureForNode(Width, Height, DefaultColor); } if (selectedNodeStyle == null || selectedNodeStyle.normal.background == null) { selectedNodeStyle = new GUIStyle(); selectedNodeStyle.normal.background = DialogueEditorUtil.MakeTextureForNode(Width, Height, SelectedColor); } if (npcNameStyle == null) { npcNameStyle = new GUIStyle(); npcNameStyle.normal.textColor = new Color(0.8f, 0.8f, 0.8f, 1); npcNameStyle.wordWrap = true; npcNameStyle.stretchHeight = false; npcNameStyle.alignment = TextAnchor.MiddleCenter; npcNameStyle.clipping = TextClipping.Clip; } currentBoxStyle = defaultNodeStyle; CreateRect(pos, Width, Height); }
public void DrawConnections(EditableConnection currentlySelected) { Vector2 start = Vector2.zero; Vector2 end = Vector2.zero; float xPos = 0; float yPos = 0; for (int i = 0; i < Info.Connections.Count; i++) { bool connectingToOption = false; if (Info.Connections[i].ConnectionType == EditableConnection.eConnectiontype.Speech) { EditableSpeechConnection connection = Info.Connections[i] as EditableSpeechConnection; DialogueEditorUtil.GetConnectionDrawInfo(rect, connection.Speech, out start, out end); xPos = connection.Speech.EditorInfo.xPos; yPos = connection.Speech.EditorInfo.yPos; } else if (Info.Connections[i].ConnectionType == EditableConnection.eConnectiontype.Option) { EditableOptionConnection connection = Info.Connections[i] as EditableOptionConnection; DialogueEditorUtil.GetConnectionDrawInfo(rect, connection.Option, out start, out end); xPos = connection.Option.EditorInfo.xPos; yPos = connection.Option.EditorInfo.yPos; connectingToOption = true; } bool selected = (currentlySelected != null && currentlySelected == Info.Connections[i]); Vector2 toStart = (start - end).normalized; Vector2 toEnd = (end - start).normalized; if (selected) { Handles.DrawBezier(start, end, start + toStart, end + toEnd, SelectedColor, null, LINE_WIDTH * 3); } Handles.DrawBezier(start, end, start + toStart, end + toEnd, DefaultColor, null, LINE_WIDTH); Vector2 intersection; Vector2 boxPos = new Vector2(xPos, yPos); if (DialogueEditorUtil.DoesLineIntersectWithBox(start, end, boxPos, connectingToOption, out intersection)) { if (selected) { DialogueEditorUtil.DrawArrowTip(intersection, toEnd, SelectedColor, LINE_WIDTH * 3); } DialogueEditorUtil.DrawArrowTip(intersection, toEnd, DefaultColor); } } }
private void InitGUIStyles() { // Panel style panelStyle = new GUIStyle(); panelStyle.normal.background = DialogueEditorUtil.MakeTexture(10, 10, DialogueEditorUtil.GetEditorColor()); // Panel title style panelTitleStyle = new GUIStyle(); panelTitleStyle.alignment = TextAnchor.MiddleCenter; panelTitleStyle.fontStyle = FontStyle.Bold; // Resizer style resizerStyle = new GUIStyle(); resizerStyle.normal.background = EditorGUIUtility.Load("icons/d_AvatarBlendBackground.png") as Texture2D; }
//--------------------------------- // Constructor //--------------------------------- public UIOptionNode(EditableConversationNode infoNode, Vector2 pos) : base(infoNode, pos) { if (defaultNodeStyle == null || defaultNodeStyle.normal.background == null) { defaultNodeStyle = new GUIStyle(); defaultNodeStyle.normal.background = DialogueEditorUtil.MakeTextureForNode(Width, Height, DefaultColor); } if (selectedNodeStyle == null || selectedNodeStyle.normal.background == null) { selectedNodeStyle = new GUIStyle(); selectedNodeStyle.normal.background = DialogueEditorUtil.MakeTextureForNode(Width, Height, SelectedColor); } currentBoxStyle = defaultNodeStyle; CreateRect(pos, Width, Height); }
public override void DrawConnections() { if (OptionNode.Speech != null) { Vector2 start, end; DialogueEditorUtil.GetConnectionDrawInfo(rect, OptionNode.Speech, out start, out end); Vector2 toStart = (start - end).normalized; Vector2 toEnd = (end - start).normalized; Handles.DrawBezier(start, end, start + toStart, end + toEnd, DefaultColor, null, LINE_WIDTH); Vector2 intersection; Vector2 boxPos = new Vector2(OptionNode.Speech.EditorInfo.xPos, OptionNode.Speech.EditorInfo.yPos); if (DialogueEditorUtil.DoesLineIntersectWithBox(start, end, boxPos, false, out intersection)) { DialogueEditorUtil.DrawArrowTip(intersection, toEnd, DefaultColor); } } }
private void ProcessEvents(Event e) { dragDelta = Vector2.zero; switch (e.type) { case UnityEngine.EventType.MouseDown: // Left click if (e.button == 0) { if (panelRect.Contains(e.mousePosition)) { clickInBox = true; } else if (InPanelDrag(e.mousePosition)) { clickInBox = true; m_inputState = eInputState.draggingPanel; } else if (e.mousePosition.y > TOOLBAR_HEIGHT) { clickInBox = false; if (!DialogueEditorWindow.NodeClickedOnThisUpdate) { UnselectNode(); e.Use(); } } } // Right click else if (e.button == 1) { if (DialogueEditorUtil.IsPointerNearConnection(uiNodes, e.mousePosition, out m_connectionDeleteParent, out m_connectionDeleteChild)) { GenericMenu rightClickMenu = new GenericMenu(); rightClickMenu.AddItem(new GUIContent("Delete connection"), false, DeleteConnection); rightClickMenu.ShowAsContext(); } } if (e.button == 0 || e.button == 2) { dragging = true; } else { dragging = false; } break; case UnityEngine.EventType.MouseDrag: if (dragging && (e.button == 0 || e.button == 2) && !clickInBox && !IsANodeSelected()) { OnDrag(e.delta); } break; case UnityEngine.EventType.MouseUp: dragging = false; break; } }