void SelectNode() { int controlID = GUIUtility.GetControlID(FocusType.Passive); if (!canvasRect.Contains(_cachedMousePosition)) { return; } switch (_currentEvent.rawType) { case EventType.MouseDown: if (_currentEvent.button == 2) { return; } _selectType = SelectType.None; if (_makeTranstion) { Node node = MouseOverNode(); if (node != null && node != _selectNodes [0]) { if (node.type == NodeType.Node) { AddTranstition(_selectNodes [0], node); } else { TransitionGroup(_selectNodes [0], node); } } _makeTranstion = false; _selectNodes.Clear(); } else { //Select Node GUIUtility.hotControl = controlID; selectionStartPosition = _cachedMousePosition; _selectTransition = null; Node node = MouseOverNode(); if (node != null) { if (_selectNodes.Count > 0 && node == _selectNodes [0] && _currentEvent.clickCount == 2 && node.type == NodeType.NodeGroup) { if (node.GetPath() != _currentGroupPath) { //double SelectGroup(node); } else { SelectGroupUp(node); } } else { _selectNodes.Clear(); _selectNodes.Add(node); GUIUtility.hotControl = 0; GUIUtility.keyboardControl = 0; if (node.type == NodeType.Node) { _selectType = SelectType.Node; } else { _selectType = SelectType.NodeGroud; } } } else { for (int i = 0; i < _transitionLines.Count; i++) { if (CheckPointInLine(_transitionLines[i].startPos, _transitionLines[i].endPos, _cachedMousePosition, 1)) { _selectTransition = _transitionLines[i].line; _selectType = SelectType.Transition; } } } selectionMode = NodeSelectionMode.Pick; //Select Trasnstion } break; case EventType.MouseUp: _draging = false; if (GUIUtility.hotControl == controlID) { selectionMode = NodeSelectionMode.None; GUIUtility.hotControl = 0; _currentEvent.Use(); } break; case EventType.MouseDrag: _selectTransition = null; if (GUIUtility.hotControl == controlID && !EditorGUI.actionKey && !_currentEvent.shift && (selectionMode == NodeSelectionMode.Pick || selectionMode == NodeSelectionMode.Rect)) { selectionMode = NodeSelectionMode.Rect; SelectNodesInRect(FromToRect(selectionStartPosition, _cachedMousePosition)); _selectType = _selectNodes.Count > 1?SelectType.NodeGroud:SelectType.Node; _currentEvent.Use(); } break; case EventType.Repaint: if (GUIUtility.hotControl == controlID && selectionMode == NodeSelectionMode.Rect) { NodeStyles.selectionRect.Draw(FromToRect(selectionStartPosition, _cachedMousePosition), false, false, false, false); } break; } }
public void AddTransition(NodeTransition target) { transition = ArrayUtility.Add <NodeTransition>(transition, target); }
/// <summary> /// 移除指定Transition /// </summary> /// <param name="target">Target.</param> public void RemoveTransition(NodeTransition target) { transition = ArrayUtility.Remove <NodeTransition>(transition, target); }
public DrawTransitionLine(NodeTransition _line, Vector2 _start, Vector2 _end) { line = _line; startPos = _start; endPos = _end; }