private void HandleDragHierachyNodes(TreeData treeData, List<HierachyNode> nodes) { if (this.dragNode == null) { this.isDragging = false; this.dropNode = null; } int controlID = GUIUtility.GetControlID(FocusType.Passive); EventType typeForControl = Event.current.GetTypeForControl(controlID); if ((typeForControl == EventType.MouseDown) && (Event.current.button == 0)) { for (int i = 0; i < nodes.Count; i++) { if ((nodes[i].rect.Contains(Event.current.mousePosition) && !this.GetHierachyNodeVisRect(nodes[i].rect).Contains(Event.current.mousePosition)) && !(nodes[i].group is TreeGroupRoot)) { this.dragClickPos = Event.current.mousePosition; this.dragNode = nodes[i]; GUIUtility.hotControl = controlID; Event.current.Use(); break; } } } if (this.dragNode != null) { this.dropNode = null; for (int j = 0; j < nodes.Count; j++) { if (nodes[j].rect.Contains(Event.current.mousePosition)) { TreeGroup ancestor = this.dragNode.group; TreeGroup group = nodes[j].group; if (((group != ancestor) && group.CanHaveSubGroups()) && ((treeData.GetGroup(ancestor.parentGroupID) != group) && !treeData.IsAncestor(ancestor, group))) { this.dropNode = nodes[j]; break; } } } switch (typeForControl) { case EventType.MouseMove: case EventType.MouseDrag: { Vector2 vector = this.dragClickPos - Event.current.mousePosition; if (vector.magnitude > 10f) { this.isDragging = true; } Event.current.Use(); break; } default: if ((typeForControl == EventType.MouseUp) && (GUIUtility.hotControl == controlID)) { if (this.dropNode != null) { this.UndoStoreSelected(EditMode.Everything); TreeGroup g = this.dragNode.group; TreeGroup parent = this.dropNode.group; treeData.SetGroupParent(g, parent); this.m_WantCompleteUpdate = true; } else { base.Repaint(); } this.dragNode = null; this.dropNode = null; GUIUtility.hotControl = 0; Event.current.Use(); } break; } } }
private void HandleDragHierachyNodes(TreeData treeData, List<TreeEditor.HierachyNode> nodes) { if (this.dragNode == null) { this.isDragging = false; this.dropNode = null; } int controlID = GUIUtility.GetControlID(FocusType.Passive); EventType typeForControl = Event.current.GetTypeForControl(controlID); if (typeForControl == EventType.MouseDown && Event.current.button == 0) { for (int i = 0; i < nodes.Count; i++) { if (nodes[i].rect.Contains(Event.current.mousePosition)) { if (!this.GetHierachyNodeVisRect(nodes[i].rect).Contains(Event.current.mousePosition)) { if (!(nodes[i].group is TreeGroupRoot)) { this.dragClickPos = Event.current.mousePosition; this.dragNode = nodes[i]; GUIUtility.hotControl = controlID; Event.current.Use(); break; } } } } } if (this.dragNode != null) { this.dropNode = null; for (int j = 0; j < nodes.Count; j++) { if (nodes[j].rect.Contains(Event.current.mousePosition)) { TreeGroup group = this.dragNode.group; TreeGroup group2 = nodes[j].group; if (group2 != group) { if (group2.CanHaveSubGroups()) { if (treeData.GetGroup(group.parentGroupID) != group2) { if (!treeData.IsAncestor(group, group2)) { this.dropNode = nodes[j]; break; } } } } } } if (typeForControl == EventType.MouseMove || typeForControl == EventType.MouseDrag) { if ((this.dragClickPos - Event.current.mousePosition).magnitude > 10f) { this.isDragging = true; } Event.current.Use(); } else { if (typeForControl == EventType.MouseUp && GUIUtility.hotControl == controlID) { if (this.dropNode != null) { this.UndoStoreSelected(TreeEditor.EditMode.Everything); TreeGroup group3 = this.dragNode.group; TreeGroup group4 = this.dropNode.group; treeData.SetGroupParent(group3, group4); this.m_WantCompleteUpdate = true; } else { base.Repaint(); } this.dragNode = null; this.dropNode = null; GUIUtility.hotControl = 0; Event.current.Use(); } } } }