static private FromToRect ( Vector2 start, Vector2 end ) : |
||
start | Vector2 | |
end | Vector2 | |
return |
public void OnSceneGUI() { if (this.editing && (Selection.gameObjects.Length <= 1)) { s_SelectionColor = GUI.skin.settings.selectionColor; if (Event.current.type == EventType.Repaint) { this.DrawVertices(); } Event current = Event.current; if (current.commandName == "SelectAll") { if (current.type == EventType.ValidateCommand) { current.Use(); } if (current.type == EventType.ExecuteCommand) { int length = this.cloth.vertices.Length; for (int i = 0; i < length; i++) { this.m_Selection[i] = true; } this.SetupSelectedMeshColors(); SceneView.RepaintAll(); this.state.ToolMode = ToolMode.Select; current.Use(); } } Handles.BeginGUI(); if ((this.m_RectSelecting && (this.state.ToolMode == ToolMode.Select)) && (Event.current.type == EventType.Repaint)) { EditorStyles.selectionRect.Draw(EditorGUIExt.FromToRect(this.m_SelectStartPoint, this.m_SelectMousePoint), GUIContent.none, false, false, false, false); } Handles.EndGUI(); SceneViewOverlay.Window(new GUIContent("Cloth Constraints"), new SceneViewOverlay.WindowFunction(this.VertexEditing), 0, SceneViewOverlay.WindowDisplayOption.OneWindowPerTarget); } }
public void OnGUI() { Event current = Event.current; Handles.BeginGUI(); Vector2 mousePosition = current.mousePosition; int controlID = s_RectSelectionID; EventType typeForControl = current.GetTypeForControl(controlID); switch (typeForControl) { case EventType.MouseDown: if ((HandleUtility.nearestControl == controlID) && (current.button == 0)) { GUIUtility.hotControl = controlID; this.m_SelectStartPoint = mousePosition; this.m_SelectionStart = Selection.objects; this.m_RectSelecting = false; } goto Label_04F7; case EventType.MouseUp: if ((GUIUtility.hotControl == controlID) && (current.button == 0)) { GUIUtility.hotControl = 0; if (!this.m_RectSelecting) { if (current.shift || EditorGUI.actionKey) { GameObject obj5 = HandleUtility.PickGameObject(current.mousePosition, false); if (!EditorGUI.actionKey ? (Selection.activeGameObject == obj5) : Selection.gameObjects.Contains <GameObject>(obj5)) { UpdateSelection(this.m_SelectionStart, obj5, SelectionType.Subtractive, this.m_RectSelecting); } else { UpdateSelection(this.m_SelectionStart, HandleUtility.PickGameObject(current.mousePosition, true), SelectionType.Additive, this.m_RectSelecting); } } else { GameObject newObject = SceneViewPicking.PickGameObject(current.mousePosition); UpdateSelection(this.m_SelectionStart, newObject, SelectionType.Normal, this.m_RectSelecting); } current.Use(); } else { EditorApplication.modifierKeysChanged = (EditorApplication.CallbackFunction)Delegate.Remove(EditorApplication.modifierKeysChanged, new EditorApplication.CallbackFunction(this.SendCommandsOnModifierKeys)); this.m_RectSelecting = false; this.m_SelectionStart = new UnityEngine.Object[0]; current.Use(); } } goto Label_04F7; case EventType.MouseDrag: if (GUIUtility.hotControl != controlID) { goto Label_04F7; } if (!this.m_RectSelecting) { Vector2 vector2 = mousePosition - this.m_SelectStartPoint; if (vector2.magnitude > 6f) { EditorApplication.modifierKeysChanged = (EditorApplication.CallbackFunction)Delegate.Combine(EditorApplication.modifierKeysChanged, new EditorApplication.CallbackFunction(this.SendCommandsOnModifierKeys)); this.m_RectSelecting = true; this.m_LastSelection = null; this.m_CurrentSelection = null; } } if (this.m_RectSelecting) { float x = Mathf.Max(mousePosition.x, 0f); this.m_SelectMousePoint = new Vector2(x, Mathf.Max(mousePosition.y, 0f)); GameObject[] newObjects = HandleUtility.PickRectObjects(EditorGUIExt.FromToRect(this.m_SelectStartPoint, this.m_SelectMousePoint)); this.m_CurrentSelection = newObjects; bool flag = false; if (this.m_LastSelection == null) { this.m_LastSelection = new Dictionary <GameObject, bool>(); flag = true; } flag |= this.m_LastSelection.Count != newObjects.Length; if (!flag) { Dictionary <GameObject, bool> dictionary = new Dictionary <GameObject, bool>(newObjects.Length); foreach (GameObject obj2 in newObjects) { dictionary.Add(obj2, false); } foreach (GameObject obj3 in this.m_LastSelection.Keys) { if (!dictionary.ContainsKey(obj3)) { flag = true; break; } } } if (flag) { this.m_LastSelection = new Dictionary <GameObject, bool>(newObjects.Length); foreach (GameObject obj4 in newObjects) { this.m_LastSelection.Add(obj4, false); } if (newObjects != null) { if (current.shift) { UpdateSelection(this.m_SelectionStart, newObjects, SelectionType.Additive, this.m_RectSelecting); } else if (EditorGUI.actionKey) { UpdateSelection(this.m_SelectionStart, newObjects, SelectionType.Subtractive, this.m_RectSelecting); } else { UpdateSelection(this.m_SelectionStart, newObjects, SelectionType.Normal, this.m_RectSelecting); } } } } break; case EventType.Repaint: if ((GUIUtility.hotControl == controlID) && this.m_RectSelecting) { EditorStyles.selectionRect.Draw(EditorGUIExt.FromToRect(this.m_SelectStartPoint, this.m_SelectMousePoint), GUIContent.none, false, false, false, false); } goto Label_04F7; case EventType.Layout: if (!Tools.viewToolActive) { HandleUtility.AddDefaultControl(controlID); } goto Label_04F7; default: if ((typeForControl == EventType.ExecuteCommand) && ((controlID == GUIUtility.hotControl) && (current.commandName == "ModifierKeysChanged"))) { if (current.shift) { UpdateSelection(this.m_SelectionStart, this.m_CurrentSelection, SelectionType.Additive, this.m_RectSelecting); } else if (EditorGUI.actionKey) { UpdateSelection(this.m_SelectionStart, this.m_CurrentSelection, SelectionType.Subtractive, this.m_RectSelecting); } else { UpdateSelection(this.m_SelectionStart, this.m_CurrentSelection, SelectionType.Normal, this.m_RectSelecting); } current.Use(); } goto Label_04F7; } current.Use(); Label_04F7: Handles.EndGUI(); }
public void OnGUI() { Event current = Event.current; Handles.BeginGUI(); Vector2 mousePosition = current.mousePosition; int num = this.k_RectSelectionID; switch (current.GetTypeForControl(num)) { case EventType.MouseDown: if (HandleUtility.nearestControl == num && current.button == 0) { GUIUtility.hotControl = num; this.m_SelectStartPoint = mousePosition; } break; case EventType.MouseUp: if (GUIUtility.hotControl == num && current.button == 0) { GUIUtility.hotControl = 0; GUIUtility.keyboardControl = 0; if (this.m_RectSelecting) { this.m_SelectMousePoint = new Vector2(mousePosition.x, mousePosition.y); ShapeEditor.SelectionType type = ShapeEditor.SelectionType.Normal; if (Event.current.control) { type = ShapeEditor.SelectionType.Subtractive; } else if (Event.current.shift) { type = ShapeEditor.SelectionType.Additive; } this.RectSelect(EditorGUIExt.FromToRect(this.m_SelectMousePoint, this.m_SelectStartPoint), type); this.m_RectSelecting = false; current.Use(); } else { this.m_SelectedPoints.Clear(); this.m_ShapeEditor.activePoint = -1; this.m_ShapeEditor.Repaint(); current.Use(); } } break; case EventType.MouseDrag: if (GUIUtility.hotControl == num) { if (!this.m_RectSelecting && (mousePosition - this.m_SelectStartPoint).magnitude > 6f) { this.m_RectSelecting = true; } if (this.m_RectSelecting) { this.m_SelectMousePoint = new Vector2(mousePosition.x, mousePosition.y); ShapeEditor.SelectionType type2 = ShapeEditor.SelectionType.Normal; if (Event.current.control) { type2 = ShapeEditor.SelectionType.Subtractive; } else if (Event.current.shift) { type2 = ShapeEditor.SelectionType.Additive; } this.RectSelect(EditorGUIExt.FromToRect(this.m_SelectMousePoint, this.m_SelectStartPoint), type2); } current.Use(); } break; case EventType.Repaint: if (GUIUtility.hotControl == num && this.m_RectSelecting) { EditorStyles.selectionRect.Draw(EditorGUIExt.FromToRect(this.m_SelectStartPoint, this.m_SelectMousePoint), GUIContent.none, false, false, false, false); } break; case EventType.Layout: if (!Tools.viewToolActive) { HandleUtility.AddDefaultControl(num); } break; } Handles.EndGUI(); }
private void SelectPointsInRect(Rect r, SelectionType st) { var localRect = EditorGUIExt.FromToRect(ScreenToLocal(r.min), ScreenToLocal(r.max)); m_Selection.RectSelect(localRect, st); }
public void OnGUI() { Event evt = Event.current; Handles.BeginGUI(); Vector2 mousePos = evt.mousePosition; int id = s_RectSelectionID; switch (evt.GetTypeForControl(id)) { case EventType.Layout: case EventType.MouseMove: if (!Tools.viewToolActive) { HandleUtility.AddDefaultControl(id); } //Handle the case of the drag being canceled if (m_RectSelecting && GUIUtility.hotControl != id) { CompleteRectSelection(); } break; case EventType.MouseDown: if (HandleUtility.nearestControl == id && evt.button == 0) { GUIUtility.hotControl = id; m_SelectStartPoint = mousePos; m_SelectionStart = Selection.objects; m_RectSelecting = false; } break; case EventType.MouseDrag: if (GUIUtility.hotControl == id) { if (!m_RectSelecting && (mousePos - m_SelectStartPoint).magnitude > 6f) { EditorApplication.modifierKeysChanged += SendCommandsOnModifierKeys; m_RectSelecting = true; ActiveEditorTracker.delayFlushDirtyRebuild = true; m_LastSelection = null; m_CurrentSelection = null; rectSelectionStarting(); } if (m_RectSelecting) { m_SelectMousePoint = new Vector2(Mathf.Max(mousePos.x, 0), Mathf.Max(mousePos.y, 0)); GameObject[] rectObjs = HandleUtility.PickRectObjects(EditorGUIExt.FromToRect(m_SelectStartPoint, m_SelectMousePoint)); m_CurrentSelection = rectObjs; bool setIt = false; if (m_LastSelection == null) { m_LastSelection = new Dictionary <GameObject, bool>(); setIt = true; } setIt |= m_LastSelection.Count != rectObjs.Length; if (!setIt) { Dictionary <GameObject, bool> set = new Dictionary <GameObject, bool>(rectObjs.Length); foreach (GameObject g in rectObjs) { set.Add(g, false); } foreach (GameObject g in m_LastSelection.Keys) { if (!set.ContainsKey(g)) { setIt = true; break; } } } if (setIt) { m_LastSelection = new Dictionary <GameObject, bool>(rectObjs.Length); foreach (GameObject g in rectObjs) { m_LastSelection.Add(g, false); } if (evt.shift) { UpdateSelection(m_SelectionStart, rectObjs, SelectionType.Additive, m_RectSelecting); } else if (EditorGUI.actionKey) { UpdateSelection(m_SelectionStart, rectObjs, SelectionType.Subtractive, m_RectSelecting); } else { UpdateSelection(m_SelectionStart, rectObjs, SelectionType.Normal, m_RectSelecting); } } } evt.Use(); } break; case EventType.Repaint: if (GUIUtility.hotControl == id && m_RectSelecting) { EditorStyles.selectionRect.Draw(EditorGUIExt.FromToRect(m_SelectStartPoint, m_SelectMousePoint), GUIContent.none, false, false, false, false); } break; case EventType.MouseUp: if (GUIUtility.hotControl == id && evt.button == 0) { GUIUtility.hotControl = 0; if (m_RectSelecting) { CompleteRectSelection(); evt.Use(); } else { if (evt.shift || EditorGUI.actionKey) { // For shift, we check if EXACTLY the active GO is hovered by mouse and then subtract. Otherwise additive. // For control/cmd, we check if ANY of the selected GO is hovered by mouse and then subtract. Otherwise additive. // Control/cmd takes priority over shift. GameObject hovered = HandleUtility.PickGameObject(evt.mousePosition, false); var handledIt = false; // shift-click deselects only if the active GO is exactly what we clicked on if (!EditorGUI.actionKey && Selection.activeGameObject == hovered) { UpdateSelection(m_SelectionStart, hovered, SelectionType.Subtractive, m_RectSelecting); handledIt = true; } // ctrl-click deselects everything up to prefab root, that is already selected if (!handledIt && EditorGUI.actionKey) { var selectedGos = Selection.gameObjects; var hoveredRoot = HandleUtility.FindSelectionBaseForPicking(hovered); var deselectList = new List <Object>(); while (hovered != null) { if (selectedGos.Contains(hovered)) { deselectList.Add(hovered); } if (hovered == hoveredRoot) { break; } var parent = hovered.transform.parent; if (parent) { hovered = parent.gameObject; } else { break; } } if (deselectList.Any()) { UpdateSelection(m_SelectionStart, deselectList.ToArray(), SelectionType.Subtractive, m_RectSelecting); handledIt = true; } } // we did not deselect anything, so add the new thing into selection instead if (!handledIt) { UpdateSelection(m_SelectionStart, HandleUtility.PickGameObject(evt.mousePosition, true), SelectionType.Additive, m_RectSelecting); } } else // With no modifier keys, we do the "cycle through overlapped" picking logic in SceneViewPicking.cs { GameObject picked = SceneViewPicking.PickGameObject(evt.mousePosition); UpdateSelection(m_SelectionStart, picked, SelectionType.Normal, m_RectSelecting); } evt.Use(); } } break; case EventType.ExecuteCommand: if (id == GUIUtility.hotControl && evt.commandName == EventCommandNames.ModifierKeysChanged) { if (evt.shift) { UpdateSelection(m_SelectionStart, m_CurrentSelection, SelectionType.Additive, m_RectSelecting); } else if (EditorGUI.actionKey) { UpdateSelection(m_SelectionStart, m_CurrentSelection, SelectionType.Subtractive, m_RectSelecting); } else { UpdateSelection(m_SelectionStart, m_CurrentSelection, SelectionType.Normal, m_RectSelecting); } evt.Use(); } break; } Handles.EndGUI(); }
public void OnGUI() { Event evt = Event.current; Handles.BeginGUI(); Vector2 mousePos = evt.mousePosition; int id = m_RectSelectionID; switch (evt.GetTypeForControl(id)) { case EventType.Layout: if (!Tools.viewToolActive) { HandleUtility.AddDefaultControl(id); } break; case EventType.MouseDown: if (HandleUtility.nearestControl == id && evt.button == 0) { guiUtility.hotControl = id; m_SelectStartPoint = mousePos; } break; case EventType.MouseDrag: if (guiUtility.hotControl == id) { if (!m_RectSelecting && (mousePos - m_SelectStartPoint).magnitude > k_MinSelectionSize) { m_RectSelecting = true; } if (m_RectSelecting) { m_SelectMousePoint = mousePos; SelectionType type = SelectionType.Normal; if (Event.current.control) { type = SelectionType.Subtractive; } else if (Event.current.shift) { type = SelectionType.Additive; } RectSelect(EditorGUIExt.FromToRect(m_SelectStartPoint, m_SelectMousePoint), type); } evt.Use(); } break; case EventType.Repaint: if (guiUtility.hotControl == id && m_RectSelecting) { EditorStyles.selectionRect.Draw(EditorGUIExt.FromToRect(m_SelectStartPoint, m_SelectMousePoint), GUIContent.none, false, false, false, false); } break; case EventType.MouseUp: if (guiUtility.hotControl == id && evt.button == 0) { guiUtility.hotControl = 0; guiUtility.keyboardControl = 0; if (m_RectSelecting) { m_SelectMousePoint = new Vector2(mousePos.x, mousePos.y); SelectionType type = SelectionType.Normal; if (Event.current.control) { type = SelectionType.Subtractive; } else if (Event.current.shift) { type = SelectionType.Additive; } RectSelect(EditorGUIExt.FromToRect(m_SelectStartPoint, m_SelectMousePoint), type); m_RectSelecting = false; } else { ClearSelection(); } evt.Use(); } break; } Handles.EndGUI(); }
public void OnGUI() { Event evt = Event.current; Handles.BeginGUI(); Vector2 mousePos = evt.mousePosition; int id = s_RectSelectionID; switch (evt.GetTypeForControl(id)) { case EventType.Layout: case EventType.MouseMove: if (!Tools.viewToolActive) { HandleUtility.AddDefaultControl(id); } break; case EventType.MouseDown: if (HandleUtility.nearestControl == id && evt.button == 0) { GUIUtility.hotControl = id; m_SelectStartPoint = mousePos; m_SelectionStart = Selection.objects; m_RectSelecting = false; } break; case EventType.MouseDrag: if (GUIUtility.hotControl == id) { if (!m_RectSelecting && (mousePos - m_SelectStartPoint).magnitude > 6f) { EditorApplication.modifierKeysChanged += SendCommandsOnModifierKeys; m_RectSelecting = true; ActiveEditorTracker.delayFlushDirtyRebuild = true; m_LastSelection = null; m_CurrentSelection = null; rectSelectionStarting(); } if (m_RectSelecting) { m_SelectMousePoint = new Vector2(Mathf.Max(mousePos.x, 0), Mathf.Max(mousePos.y, 0)); GameObject[] rectObjs = HandleUtility.PickRectObjects(EditorGUIExt.FromToRect(m_SelectStartPoint, m_SelectMousePoint)); m_CurrentSelection = rectObjs; bool setIt = false; if (m_LastSelection == null) { m_LastSelection = new Dictionary <GameObject, bool>(); setIt = true; } setIt |= m_LastSelection.Count != rectObjs.Length; if (!setIt) { Dictionary <GameObject, bool> set = new Dictionary <GameObject, bool>(rectObjs.Length); foreach (GameObject g in rectObjs) { set.Add(g, false); } foreach (GameObject g in m_LastSelection.Keys) { if (!set.ContainsKey(g)) { setIt = true; break; } } } if (setIt) { m_LastSelection = new Dictionary <GameObject, bool>(rectObjs.Length); foreach (GameObject g in rectObjs) { m_LastSelection.Add(g, false); } if (evt.shift) { UpdateSelection(m_SelectionStart, rectObjs, SelectionType.Additive, m_RectSelecting); } else if (EditorGUI.actionKey) { UpdateSelection(m_SelectionStart, rectObjs, SelectionType.Subtractive, m_RectSelecting); } else { UpdateSelection(m_SelectionStart, rectObjs, SelectionType.Normal, m_RectSelecting); } } } evt.Use(); } break; case EventType.Repaint: if (GUIUtility.hotControl == id && m_RectSelecting) { EditorStyles.selectionRect.Draw(EditorGUIExt.FromToRect(m_SelectStartPoint, m_SelectMousePoint), GUIContent.none, false, false, false, false); } break; case EventType.MouseUp: if (GUIUtility.hotControl == id && evt.button == 0) { GUIUtility.hotControl = 0; if (m_RectSelecting) { EditorApplication.modifierKeysChanged -= SendCommandsOnModifierKeys; m_RectSelecting = false; ActiveEditorTracker.delayFlushDirtyRebuild = false; ActiveEditorTracker.RebuildAllIfNecessary(); m_SelectionStart = new Object[0]; rectSelectionFinished(); evt.Use(); } else { if (evt.shift || EditorGUI.actionKey) { // For shift, we check if EXACTLY the active GO is hovered by mouse and then subtract. Otherwise additive. // For control/cmd, we check if ANY of the selected GO is hovered by mouse and then subtract. Otherwise additive. // Control/cmd takes priority over shift. GameObject hovered = HandleUtility.PickGameObject(evt.mousePosition, false); if (EditorGUI.actionKey ? Selection.gameObjects.Contains(hovered) : Selection.activeGameObject == hovered) { UpdateSelection(m_SelectionStart, hovered, SelectionType.Subtractive, m_RectSelecting); } else { UpdateSelection(m_SelectionStart, HandleUtility.PickGameObject(evt.mousePosition, true), SelectionType.Additive, m_RectSelecting); } } else // With no modifier keys, we do the "cycle through overlapped" picking logic in SceneViewPicking.cs { GameObject picked = SceneViewPicking.PickGameObject(evt.mousePosition); UpdateSelection(m_SelectionStart, picked, SelectionType.Normal, m_RectSelecting); } evt.Use(); } } break; case EventType.ExecuteCommand: if (id == GUIUtility.hotControl && evt.commandName == EventCommandNames.ModifierKeysChanged) { if (evt.shift) { UpdateSelection(m_SelectionStart, m_CurrentSelection, SelectionType.Additive, m_RectSelecting); } else if (EditorGUI.actionKey) { UpdateSelection(m_SelectionStart, m_CurrentSelection, SelectionType.Subtractive, m_RectSelecting); } else { UpdateSelection(m_SelectionStart, m_CurrentSelection, SelectionType.Normal, m_RectSelecting); } evt.Use(); } break; } Handles.EndGUI(); }
public void OnGUI() { Event current = Event.current; Handles.BeginGUI(); Vector2 mousePosition = current.mousePosition; int num = RectSelection.s_RectSelectionID; EventType typeForControl = current.GetTypeForControl(num); switch (typeForControl) { case EventType.MouseDown: if (HandleUtility.nearestControl == num && current.button == 0) { GUIUtility.hotControl = num; this.m_SelectStartPoint = mousePosition; this.m_SelectionStart = Selection.objects; this.m_RectSelecting = false; } goto IL_4F7; case EventType.MouseUp: if (GUIUtility.hotControl == num && current.button == 0) { GUIUtility.hotControl = 0; if (this.m_RectSelecting) { EditorApplication.modifierKeysChanged = (EditorApplication.CallbackFunction)Delegate.Remove(EditorApplication.modifierKeysChanged, new EditorApplication.CallbackFunction(this.SendCommandsOnModifierKeys)); this.m_RectSelecting = false; this.m_SelectionStart = new UnityEngine.Object[0]; current.Use(); } else { if (current.shift || EditorGUI.actionKey) { GameObject gameObject = HandleUtility.PickGameObject(current.mousePosition, false); if ((!EditorGUI.actionKey) ? (Selection.activeGameObject == gameObject) : Selection.gameObjects.Contains(gameObject)) { RectSelection.UpdateSelection(this.m_SelectionStart, gameObject, RectSelection.SelectionType.Subtractive, this.m_RectSelecting); } else { RectSelection.UpdateSelection(this.m_SelectionStart, HandleUtility.PickGameObject(current.mousePosition, true), RectSelection.SelectionType.Additive, this.m_RectSelecting); } } else { GameObject newObject = SceneViewPicking.PickGameObject(current.mousePosition); RectSelection.UpdateSelection(this.m_SelectionStart, newObject, RectSelection.SelectionType.Normal, this.m_RectSelecting); } current.Use(); } } goto IL_4F7; case EventType.MouseMove: case EventType.KeyDown: case EventType.KeyUp: case EventType.ScrollWheel: IL_4B: if (typeForControl != EventType.ExecuteCommand) { goto IL_4F7; } if (num == GUIUtility.hotControl && current.commandName == "ModifierKeysChanged") { if (current.shift) { RectSelection.UpdateSelection(this.m_SelectionStart, this.m_CurrentSelection, RectSelection.SelectionType.Additive, this.m_RectSelecting); } else if (EditorGUI.actionKey) { RectSelection.UpdateSelection(this.m_SelectionStart, this.m_CurrentSelection, RectSelection.SelectionType.Subtractive, this.m_RectSelecting); } else { RectSelection.UpdateSelection(this.m_SelectionStart, this.m_CurrentSelection, RectSelection.SelectionType.Normal, this.m_RectSelecting); } current.Use(); } goto IL_4F7; case EventType.MouseDrag: if (GUIUtility.hotControl == num) { if (!this.m_RectSelecting && (mousePosition - this.m_SelectStartPoint).magnitude > 6f) { EditorApplication.modifierKeysChanged = (EditorApplication.CallbackFunction)Delegate.Combine(EditorApplication.modifierKeysChanged, new EditorApplication.CallbackFunction(this.SendCommandsOnModifierKeys)); this.m_RectSelecting = true; this.m_LastSelection = null; this.m_CurrentSelection = null; } if (this.m_RectSelecting) { this.m_SelectMousePoint = new Vector2(Mathf.Max(mousePosition.x, 0f), Mathf.Max(mousePosition.y, 0f)); GameObject[] array = HandleUtility.PickRectObjects(EditorGUIExt.FromToRect(this.m_SelectStartPoint, this.m_SelectMousePoint)); this.m_CurrentSelection = array; bool flag = false; if (this.m_LastSelection == null) { this.m_LastSelection = new Dictionary <GameObject, bool>(); flag = true; } flag |= (this.m_LastSelection.Count != array.Length); if (!flag) { Dictionary <GameObject, bool> dictionary = new Dictionary <GameObject, bool>(array.Length); GameObject[] array2 = array; for (int i = 0; i < array2.Length; i++) { GameObject key = array2[i]; dictionary.Add(key, false); } foreach (GameObject current2 in this.m_LastSelection.Keys) { if (!dictionary.ContainsKey(current2)) { flag = true; break; } } } if (flag) { this.m_LastSelection = new Dictionary <GameObject, bool>(array.Length); GameObject[] array3 = array; for (int j = 0; j < array3.Length; j++) { GameObject key2 = array3[j]; this.m_LastSelection.Add(key2, false); } if (array != null) { if (current.shift) { RectSelection.UpdateSelection(this.m_SelectionStart, array, RectSelection.SelectionType.Additive, this.m_RectSelecting); } else if (EditorGUI.actionKey) { RectSelection.UpdateSelection(this.m_SelectionStart, array, RectSelection.SelectionType.Subtractive, this.m_RectSelecting); } else { RectSelection.UpdateSelection(this.m_SelectionStart, array, RectSelection.SelectionType.Normal, this.m_RectSelecting); } } } } current.Use(); } goto IL_4F7; case EventType.Repaint: if (GUIUtility.hotControl == num && this.m_RectSelecting) { EditorStyles.selectionRect.Draw(EditorGUIExt.FromToRect(this.m_SelectStartPoint, this.m_SelectMousePoint), GUIContent.none, false, false, false, false); } goto IL_4F7; case EventType.Layout: if (!Tools.viewToolActive) { HandleUtility.AddDefaultControl(num); } goto IL_4F7; } goto IL_4B; IL_4F7: Handles.EndGUI(); }
public void OnGUI() { Event current1 = Event.current; Handles.BeginGUI(); Vector2 mousePosition = current1.mousePosition; int rectSelectionId = RectSelection.s_RectSelectionID; EventType typeForControl = current1.GetTypeForControl(rectSelectionId); switch (typeForControl) { case EventType.MouseDown: if (HandleUtility.nearestControl == rectSelectionId && current1.button == 0) { GUIUtility.hotControl = rectSelectionId; this.m_SelectStartPoint = mousePosition; this.m_SelectionStart = Selection.objects; this.m_RectSelecting = false; break; } break; case EventType.MouseUp: if (GUIUtility.hotControl == rectSelectionId && current1.button == 0) { GUIUtility.hotControl = 0; if (this.m_RectSelecting) { EditorApplication.modifierKeysChanged -= new EditorApplication.CallbackFunction(this.SendCommandsOnModifierKeys); this.m_RectSelecting = false; this.m_SelectionStart = new UnityEngine.Object[0]; current1.Use(); break; } if (current1.shift || EditorGUI.actionKey) { GameObject[] gameObjectArray; if (current1.shift) { gameObjectArray = new GameObject[1] { Selection.activeGameObject } } ; else { gameObjectArray = Selection.gameObjects; } GameObject[] gameObjects = gameObjectArray; GameObject hovered = SceneViewPicking.GetHovered(current1.mousePosition, gameObjects); if ((UnityEngine.Object)hovered != (UnityEngine.Object)null) { RectSelection.UpdateSelection(this.m_SelectionStart, (UnityEngine.Object)hovered, RectSelection.SelectionType.Subtractive, this.m_RectSelecting); } else { RectSelection.UpdateSelection(this.m_SelectionStart, (UnityEngine.Object)HandleUtility.PickGameObject(current1.mousePosition, true), RectSelection.SelectionType.Additive, this.m_RectSelecting); } } else { RectSelection.UpdateSelection(this.m_SelectionStart, (UnityEngine.Object)SceneViewPicking.PickGameObject(current1.mousePosition), RectSelection.SelectionType.Normal, this.m_RectSelecting); } current1.Use(); break; } break; case EventType.MouseDrag: if (GUIUtility.hotControl == rectSelectionId) { if (!this.m_RectSelecting && (double)(mousePosition - this.m_SelectStartPoint).magnitude > 6.0) { EditorApplication.modifierKeysChanged += new EditorApplication.CallbackFunction(this.SendCommandsOnModifierKeys); this.m_RectSelecting = true; this.m_LastSelection = (Dictionary <GameObject, bool>)null; this.m_CurrentSelection = (UnityEngine.Object[])null; } if (this.m_RectSelecting) { this.m_SelectMousePoint = new Vector2(Mathf.Max(mousePosition.x, 0.0f), Mathf.Max(mousePosition.y, 0.0f)); GameObject[] gameObjectArray = HandleUtility.PickRectObjects(EditorGUIExt.FromToRect(this.m_SelectStartPoint, this.m_SelectMousePoint)); this.m_CurrentSelection = (UnityEngine.Object[])gameObjectArray; bool flag1 = false; if (this.m_LastSelection == null) { this.m_LastSelection = new Dictionary <GameObject, bool>(); flag1 = true; } bool flag2 = flag1 | this.m_LastSelection.Count != gameObjectArray.Length; if (!flag2) { Dictionary <GameObject, bool> dictionary = new Dictionary <GameObject, bool>(gameObjectArray.Length); foreach (GameObject key in gameObjectArray) { dictionary.Add(key, false); } using (Dictionary <GameObject, bool> .KeyCollection.Enumerator enumerator = this.m_LastSelection.Keys.GetEnumerator()) { while (enumerator.MoveNext()) { GameObject current2 = enumerator.Current; if (!dictionary.ContainsKey(current2)) { flag2 = true; break; } } } } if (flag2) { this.m_LastSelection = new Dictionary <GameObject, bool>(gameObjectArray.Length); foreach (GameObject key in gameObjectArray) { this.m_LastSelection.Add(key, false); } if (gameObjectArray != null) { if (current1.shift) { RectSelection.UpdateSelection(this.m_SelectionStart, (UnityEngine.Object[])gameObjectArray, RectSelection.SelectionType.Additive, this.m_RectSelecting); } else if (EditorGUI.actionKey) { RectSelection.UpdateSelection(this.m_SelectionStart, (UnityEngine.Object[])gameObjectArray, RectSelection.SelectionType.Subtractive, this.m_RectSelecting); } else { RectSelection.UpdateSelection(this.m_SelectionStart, (UnityEngine.Object[])gameObjectArray, RectSelection.SelectionType.Normal, this.m_RectSelecting); } } } } current1.Use(); break; } break; case EventType.Repaint: if (GUIUtility.hotControl == rectSelectionId && this.m_RectSelecting) { EditorStyles.selectionRect.Draw(EditorGUIExt.FromToRect(this.m_SelectStartPoint, this.m_SelectMousePoint), GUIContent.none, false, false, false, false); break; } break; case EventType.Layout: if (!Tools.viewToolActive) { HandleUtility.AddDefaultControl(rectSelectionId); break; } break; default: if (typeForControl == EventType.ExecuteCommand && rectSelectionId == GUIUtility.hotControl && current1.commandName == "ModifierKeysChanged") { if (current1.shift) { RectSelection.UpdateSelection(this.m_SelectionStart, this.m_CurrentSelection, RectSelection.SelectionType.Additive, this.m_RectSelecting); } else if (EditorGUI.actionKey) { RectSelection.UpdateSelection(this.m_SelectionStart, this.m_CurrentSelection, RectSelection.SelectionType.Subtractive, this.m_RectSelecting); } else { RectSelection.UpdateSelection(this.m_SelectionStart, this.m_CurrentSelection, RectSelection.SelectionType.Normal, this.m_RectSelecting); } current1.Use(); break; } break; } Handles.EndGUI(); }