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 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 static HighLevelEvent MultiSelection(Rect rect, Rect[] positions, GUIContent content, Rect[] hitPositions, ref bool[] selections, bool[] readOnly, out int clickedIndex, out Vector2 offset, out float startSelect, out float endSelect, GUIStyle style) { int controlId = GUIUtility.GetControlID(41623453, FocusType.Keyboard); Event current = Event.current; offset = Vector2.zero; clickedIndex = -1; startSelect = endSelect = 0.0f; if (current.type == EventType.Used) { return(HighLevelEvent.None); } bool flag1 = false; if (Event.current.type != EventType.Layout) { if (GUIUtility.keyboardControl == controlId) { flag1 = true; } else { selections = new bool[selections.Length]; } } EventType typeForControl = current.GetTypeForControl(controlId); switch (typeForControl) { case EventType.MouseDown: if (current.button == 0) { GUIUtility.hotControl = controlId; GUIUtility.keyboardControl = controlId; EditorGUIExt.s_StartSelectPos = current.mousePosition; int indexUnderMouse = EditorGUIExt.GetIndexUnderMouse(hitPositions, readOnly); if (Event.current.clickCount == 2 && indexUnderMouse >= 0) { for (int index = 0; index < selections.Length; ++index) { selections[index] = false; } selections[indexUnderMouse] = true; current.Use(); clickedIndex = indexUnderMouse; return(HighLevelEvent.DoubleClick); } if (indexUnderMouse >= 0) { if (!current.shift && !EditorGUI.actionKey && !selections[indexUnderMouse]) { for (int index = 0; index < hitPositions.Length; ++index) { selections[index] = false; } } selections[indexUnderMouse] = !current.shift && !EditorGUI.actionKey || !selections[indexUnderMouse]; EditorGUIExt.s_MouseDownPos = current.mousePosition; EditorGUIExt.s_MultiSelectDragSelection = EditorGUIExt.DragSelectionState.None; current.Use(); clickedIndex = indexUnderMouse; return(HighLevelEvent.SelectionChanged); } bool flag2; if (!current.shift && !EditorGUI.actionKey) { for (int index = 0; index < hitPositions.Length; ++index) { selections[index] = false; } flag2 = true; } else { flag2 = false; } EditorGUIExt.s_SelectionBackup = new List <bool>((IEnumerable <bool>)selections); EditorGUIExt.s_LastFrameSelections = new List <bool>((IEnumerable <bool>)selections); EditorGUIExt.s_MultiSelectDragSelection = EditorGUIExt.DragSelectionState.DragSelecting; current.Use(); return(flag2 ? HighLevelEvent.SelectionChanged : HighLevelEvent.None); } break; case EventType.MouseUp: if (GUIUtility.hotControl == controlId) { GUIUtility.hotControl = 0; if (EditorGUIExt.s_StartSelectPos != current.mousePosition) { current.Use(); } if (EditorGUIExt.s_MultiSelectDragSelection == EditorGUIExt.DragSelectionState.None) { clickedIndex = EditorGUIExt.GetIndexUnderMouse(hitPositions, readOnly); if (current.clickCount == 1) { return(HighLevelEvent.Click); } break; } EditorGUIExt.s_MultiSelectDragSelection = EditorGUIExt.DragSelectionState.None; EditorGUIExt.s_SelectionBackup = (List <bool>)null; EditorGUIExt.s_LastFrameSelections = (List <bool>)null; return(HighLevelEvent.EndDrag); } break; case EventType.MouseDrag: if (GUIUtility.hotControl == controlId) { if (EditorGUIExt.s_MultiSelectDragSelection == EditorGUIExt.DragSelectionState.DragSelecting) { float num1 = Mathf.Min(EditorGUIExt.s_StartSelectPos.x, current.mousePosition.x); float num2 = Mathf.Max(EditorGUIExt.s_StartSelectPos.x, current.mousePosition.x); EditorGUIExt.s_SelectionBackup.CopyTo(selections); for (int index = 0; index < hitPositions.Length; ++index) { if (!selections[index]) { float num3 = hitPositions[index].x + hitPositions[index].width * 0.5f; if ((double)num3 >= (double)num1 && (double)num3 <= (double)num2) { selections[index] = true; } } } current.Use(); startSelect = num1; endSelect = num2; bool flag2 = false; for (int index = 0; index < selections.Length; ++index) { if (selections[index] != EditorGUIExt.s_LastFrameSelections[index]) { flag2 = true; EditorGUIExt.s_LastFrameSelections[index] = selections[index]; } } return(flag2 ? HighLevelEvent.SelectionChanged : HighLevelEvent.None); } offset = current.mousePosition - EditorGUIExt.s_MouseDownPos; current.Use(); if (EditorGUIExt.s_MultiSelectDragSelection != EditorGUIExt.DragSelectionState.None) { return(HighLevelEvent.Drag); } EditorGUIExt.s_MultiSelectDragSelection = EditorGUIExt.DragSelectionState.Dragging; return(HighLevelEvent.BeginDrag); } break; case EventType.KeyDown: if (flag1 && (current.keyCode == KeyCode.Backspace || current.keyCode == KeyCode.Delete)) { current.Use(); return(HighLevelEvent.Delete); } break; case EventType.Repaint: if (GUIUtility.hotControl == controlId && EditorGUIExt.s_MultiSelectDragSelection == EditorGUIExt.DragSelectionState.DragSelecting) { float num1 = Mathf.Min(EditorGUIExt.s_StartSelectPos.x, current.mousePosition.x); float num2 = Mathf.Max(EditorGUIExt.s_StartSelectPos.x, current.mousePosition.x); Rect position = new Rect(0.0f, 0.0f, rect.width, rect.height); position.x = num1; position.width = num2 - num1; if ((double)position.width != 0.0) { GUI.Box(position, string.Empty, EditorGUIExt.ms_Styles.selectionRect); } } Color color = GUI.color; for (int index = 0; index < positions.Length; ++index) { GUI.color = readOnly == null || !readOnly[index] ? (!selections[index] ? color * new Color(0.9f, 0.9f, 0.9f, 1f) : color * new Color(0.3f, 0.55f, 0.95f, 1f)) : color * new Color(0.9f, 0.9f, 0.9f, 0.5f); style.Draw(positions[index], content, controlId, selections[index]); } GUI.color = color; break; default: switch (typeForControl - 13) { case EventType.MouseDown: case EventType.MouseUp: if (flag1) { bool flag2 = current.type == EventType.ExecuteCommand; string commandName = current.commandName; if (commandName != null) { // ISSUE: reference to a compiler-generated field if (EditorGUIExt.\u003C\u003Ef__switch\u0024mapE == null) { // ISSUE: reference to a compiler-generated field EditorGUIExt.\u003C\u003Ef__switch\u0024mapE = new Dictionary <string, int>(1) { { "Delete", 0 } }; } int num; // ISSUE: reference to a compiler-generated field if (EditorGUIExt.\u003C\u003Ef__switch\u0024mapE.TryGetValue(commandName, out num) && num == 0) { current.Use(); if (flag2) { return(HighLevelEvent.Delete); } break; } break; } break; } break; case EventType.MouseDrag: int indexUnderMouse1 = EditorGUIExt.GetIndexUnderMouse(hitPositions, readOnly); if (indexUnderMouse1 >= 0) { clickedIndex = indexUnderMouse1; GUIUtility.keyboardControl = controlId; current.Use(); return(HighLevelEvent.ContextClick); } break; } } return(HighLevelEvent.None); }
public static HighLevelEvent MultiSelection(Rect rect, Rect[] positions, GUIContent content, Rect[] hitPositions, ref bool[] selections, bool[] readOnly, out int clickedIndex, out Vector2 offset, out float startSelect, out float endSelect, GUIStyle style) { int controlID = GUIUtility.GetControlID(41623453, FocusType.Keyboard); Event current = Event.current; offset = Vector2.zero; clickedIndex = -1; startSelect = (endSelect = 0f); HighLevelEvent result; if (current.type == EventType.Used) { result = HighLevelEvent.None; } else { bool flag = false; if (Event.current.type != EventType.Layout) { if (GUIUtility.keyboardControl == controlID) { flag = true; } } EventType typeForControl = current.GetTypeForControl(controlID); switch (typeForControl) { case EventType.MouseDown: { if (current.button != 0) { goto IL_6A2; } GUIUtility.hotControl = controlID; GUIUtility.keyboardControl = controlID; EditorGUIExt.s_StartSelectPos = current.mousePosition; int indexUnderMouse = EditorGUIExt.GetIndexUnderMouse(hitPositions, readOnly); if (Event.current.clickCount == 2) { if (indexUnderMouse >= 0) { for (int i = 0; i < selections.Length; i++) { selections[i] = false; } selections[indexUnderMouse] = true; current.Use(); clickedIndex = indexUnderMouse; result = HighLevelEvent.DoubleClick; return(result); } } if (indexUnderMouse >= 0) { if (!current.shift && !EditorGUI.actionKey && !selections[indexUnderMouse]) { for (int j = 0; j < hitPositions.Length; j++) { selections[j] = false; } } if (current.shift || EditorGUI.actionKey) { selections[indexUnderMouse] = !selections[indexUnderMouse]; } else { selections[indexUnderMouse] = true; } EditorGUIExt.s_MouseDownPos = current.mousePosition; EditorGUIExt.s_MultiSelectDragSelection = EditorGUIExt.DragSelectionState.None; current.Use(); clickedIndex = indexUnderMouse; result = HighLevelEvent.SelectionChanged; return(result); } bool flag2; if (!current.shift && !EditorGUI.actionKey) { for (int k = 0; k < hitPositions.Length; k++) { selections[k] = false; } flag2 = true; } else { flag2 = false; } EditorGUIExt.s_SelectionBackup = new List <bool>(selections); EditorGUIExt.s_LastFrameSelections = new List <bool>(selections); EditorGUIExt.s_MultiSelectDragSelection = EditorGUIExt.DragSelectionState.DragSelecting; current.Use(); result = ((!flag2) ? HighLevelEvent.None : HighLevelEvent.SelectionChanged); return(result); } case EventType.MouseUp: if (GUIUtility.hotControl == controlID) { GUIUtility.hotControl = 0; if (EditorGUIExt.s_StartSelectPos != current.mousePosition) { current.Use(); } if (EditorGUIExt.s_MultiSelectDragSelection != EditorGUIExt.DragSelectionState.None) { EditorGUIExt.s_MultiSelectDragSelection = EditorGUIExt.DragSelectionState.None; EditorGUIExt.s_SelectionBackup = null; EditorGUIExt.s_LastFrameSelections = null; result = HighLevelEvent.EndDrag; return(result); } clickedIndex = EditorGUIExt.GetIndexUnderMouse(hitPositions, readOnly); if (current.clickCount == 1) { result = HighLevelEvent.Click; return(result); } } goto IL_6A2; case EventType.MouseMove: case EventType.KeyUp: case EventType.ScrollWheel: IL_98: switch (typeForControl) { case EventType.ValidateCommand: case EventType.ExecuteCommand: if (flag) { bool flag3 = current.type == EventType.ExecuteCommand; string commandName = current.commandName; if (commandName != null) { if (commandName == "Delete") { current.Use(); if (flag3) { result = HighLevelEvent.Delete; return(result); } } } } goto IL_6A2; case EventType.DragExited: goto IL_6A2; case EventType.ContextClick: { int indexUnderMouse = EditorGUIExt.GetIndexUnderMouse(hitPositions, readOnly); if (indexUnderMouse >= 0) { clickedIndex = indexUnderMouse; GUIUtility.keyboardControl = controlID; current.Use(); result = HighLevelEvent.ContextClick; return(result); } goto IL_6A2; } default: goto IL_6A2; } break; case EventType.MouseDrag: if (GUIUtility.hotControl != controlID) { goto IL_6A2; } if (EditorGUIExt.s_MultiSelectDragSelection == EditorGUIExt.DragSelectionState.DragSelecting) { float num = Mathf.Min(EditorGUIExt.s_StartSelectPos.x, current.mousePosition.x); float num2 = Mathf.Max(EditorGUIExt.s_StartSelectPos.x, current.mousePosition.x); EditorGUIExt.s_SelectionBackup.CopyTo(selections); for (int l = 0; l < hitPositions.Length; l++) { if (!selections[l]) { float num3 = hitPositions[l].x + hitPositions[l].width * 0.5f; if (num3 >= num && num3 <= num2) { selections[l] = true; } } } current.Use(); startSelect = num; endSelect = num2; bool flag4 = false; for (int m = 0; m < selections.Length; m++) { if (selections[m] != EditorGUIExt.s_LastFrameSelections[m]) { flag4 = true; EditorGUIExt.s_LastFrameSelections[m] = selections[m]; } } result = ((!flag4) ? HighLevelEvent.None : HighLevelEvent.SelectionChanged); return(result); } offset = current.mousePosition - EditorGUIExt.s_MouseDownPos; current.Use(); if (EditorGUIExt.s_MultiSelectDragSelection == EditorGUIExt.DragSelectionState.None) { EditorGUIExt.s_MultiSelectDragSelection = EditorGUIExt.DragSelectionState.Dragging; result = HighLevelEvent.BeginDrag; return(result); } result = HighLevelEvent.Drag; return(result); case EventType.KeyDown: if (flag) { if (current.keyCode == KeyCode.Backspace || current.keyCode == KeyCode.Delete) { current.Use(); result = HighLevelEvent.Delete; return(result); } } goto IL_6A2; case EventType.Repaint: { if (GUIUtility.hotControl == controlID && EditorGUIExt.s_MultiSelectDragSelection == EditorGUIExt.DragSelectionState.DragSelecting) { float num4 = Mathf.Min(EditorGUIExt.s_StartSelectPos.x, current.mousePosition.x); float num5 = Mathf.Max(EditorGUIExt.s_StartSelectPos.x, current.mousePosition.x); Rect position = new Rect(0f, 0f, rect.width, rect.height); position.x = num4; position.width = num5 - num4; if (position.width != 0f) { GUI.Box(position, "", EditorGUIExt.ms_Styles.selectionRect); } } Color color = GUI.color; for (int n = 0; n < positions.Length; n++) { if (readOnly != null && readOnly[n]) { GUI.color = color * new Color(0.9f, 0.9f, 0.9f, 0.5f); } else if (selections[n]) { GUI.color = color * new Color(0.3f, 0.55f, 0.95f, 1f); } else { GUI.color = color * new Color(0.9f, 0.9f, 0.9f, 1f); } style.Draw(positions[n], content, controlID, selections[n]); } GUI.color = color; goto IL_6A2; } } goto IL_98; IL_6A2: result = HighLevelEvent.None; } return(result); }
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 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(); }
private void SliderGUI() { if (this.m_HSlider || this.m_VSlider) { using (new EditorGUI.DisabledScope(!this.enableMouseInput)) { Bounds drawingBounds = this.drawingBounds; Rect shownAreaInsideMargins = this.shownAreaInsideMargins; float num = this.styles.sliderWidth - this.styles.visualSliderWidth; float num2 = (!this.vSlider || !this.hSlider) ? 0f : num; Vector2 a = this.m_Scale; if (this.m_HSlider) { Rect position = new Rect(this.drawRect.x + 1f, this.drawRect.yMax - num, this.drawRect.width - num2, this.styles.sliderWidth); float width = shownAreaInsideMargins.width; float num3 = shownAreaInsideMargins.xMin; if (this.m_EnableSliderZoom) { EditorGUIExt.MinMaxScroller(position, this.horizontalScrollbarID, ref num3, ref width, drawingBounds.min.x, drawingBounds.max.x, float.NegativeInfinity, float.PositiveInfinity, this.styles.horizontalScrollbar, this.styles.horizontalMinMaxScrollbarThumb, this.styles.horizontalScrollbarLeftButton, this.styles.horizontalScrollbarRightButton, true); } else { num3 = GUI.Scroller(position, num3, width, drawingBounds.min.x, drawingBounds.max.x, this.styles.horizontalScrollbar, this.styles.horizontalMinMaxScrollbarThumb, this.styles.horizontalScrollbarLeftButton, this.styles.horizontalScrollbarRightButton, true); } float num4 = num3; float num5 = num3 + width; if (num4 > shownAreaInsideMargins.xMin) { num4 = Mathf.Min(num4, num5 - this.rect.width / this.m_HScaleMax); } if (num5 < shownAreaInsideMargins.xMax) { num5 = Mathf.Max(num5, num4 + this.rect.width / this.m_HScaleMax); } this.SetShownHRangeInsideMargins(num4, num5); } if (this.m_VSlider) { if (this.m_UpDirection == ZoomableArea.YDirection.Positive) { Rect position2 = new Rect(this.drawRect.xMax - num, this.drawRect.y, this.styles.sliderWidth, this.drawRect.height - num2); float height = shownAreaInsideMargins.height; float num6 = -shownAreaInsideMargins.yMax; if (this.m_EnableSliderZoom) { EditorGUIExt.MinMaxScroller(position2, this.verticalScrollbarID, ref num6, ref height, -drawingBounds.max.y, -drawingBounds.min.y, float.NegativeInfinity, float.PositiveInfinity, this.styles.verticalScrollbar, this.styles.verticalMinMaxScrollbarThumb, this.styles.verticalScrollbarUpButton, this.styles.verticalScrollbarDownButton, false); } else { num6 = GUI.Scroller(position2, num6, height, -drawingBounds.max.y, -drawingBounds.min.y, this.styles.verticalScrollbar, this.styles.verticalMinMaxScrollbarThumb, this.styles.verticalScrollbarUpButton, this.styles.verticalScrollbarDownButton, false); } float num4 = -(num6 + height); float num5 = -num6; if (num4 > shownAreaInsideMargins.yMin) { num4 = Mathf.Min(num4, num5 - this.rect.height / this.m_VScaleMax); } if (num5 < shownAreaInsideMargins.yMax) { num5 = Mathf.Max(num5, num4 + this.rect.height / this.m_VScaleMax); } this.SetShownVRangeInsideMargins(num4, num5); } else { Rect position3 = new Rect(this.drawRect.xMax - num, this.drawRect.y, this.styles.sliderWidth, this.drawRect.height - num2); float height2 = shownAreaInsideMargins.height; float num7 = shownAreaInsideMargins.yMin; if (this.m_EnableSliderZoom) { EditorGUIExt.MinMaxScroller(position3, this.verticalScrollbarID, ref num7, ref height2, drawingBounds.min.y, drawingBounds.max.y, float.NegativeInfinity, float.PositiveInfinity, this.styles.verticalScrollbar, this.styles.verticalMinMaxScrollbarThumb, this.styles.verticalScrollbarUpButton, this.styles.verticalScrollbarDownButton, false); } else { num7 = GUI.Scroller(position3, num7, height2, drawingBounds.min.y, drawingBounds.max.y, this.styles.verticalScrollbar, this.styles.verticalMinMaxScrollbarThumb, this.styles.verticalScrollbarUpButton, this.styles.verticalScrollbarDownButton, false); } float num4 = num7; float num5 = num7 + height2; if (num4 > shownAreaInsideMargins.yMin) { num4 = Mathf.Min(num4, num5 - this.rect.height / this.m_VScaleMax); } if (num5 < shownAreaInsideMargins.yMax) { num5 = Mathf.Max(num5, num4 + this.rect.height / this.m_VScaleMax); } this.SetShownVRangeInsideMargins(num4, num5); } } if (this.uniformScale) { float num8 = this.drawRect.width / this.drawRect.height; a -= this.m_Scale; Vector2 b = new Vector2(-a.y * num8, -a.x / num8); this.m_Scale -= b; this.m_Translation.x = this.m_Translation.x - a.y / 2f; this.m_Translation.y = this.m_Translation.y - a.x / 2f; this.EnforceScaleAndRange(); } } } }
public bool HandleEventManipulation(Rect rect, ref AnimationEvent[] events, AnimationClipInfoProperties clipInfo) { Texture image = EditorGUIUtility.IconContent("Animation.EventMarker").image; bool flag = false; Rect[] rectArray = new Rect[events.Length]; Rect[] positions = new Rect[events.Length]; int num1 = 1; int num2 = 0; for (int index = 0; index < events.Length; ++index) { AnimationEvent animationEvent = events[index]; if (num2 == 0) { num1 = 1; while (index + num1 < events.Length && (double)events[index + num1].time == (double)animationEvent.time) { ++num1; } num2 = num1; } --num2; float num3 = Mathf.Floor(this.m_Timeline.TimeToPixel(animationEvent.time, rect)); int num4 = 0; if (num1 > 1) { num4 = Mathf.FloorToInt(Mathf.Max(0.0f, (float)Mathf.Min((num1 - 1) * (image.width - 1), (int)(1.0 / (double)this.m_Timeline.PixelDeltaToTime(rect) - (double)(image.width * 2))) - (float)((image.width - 1) * num2))); } Rect rect1 = new Rect(num3 + (float)num4 - (float)(image.width / 2), (rect.height - 10f) * (float)(num2 - num1 + 1) / (float)Mathf.Max(1, num1 - 1), (float)image.width, (float)image.height); rectArray[index] = rect1; positions[index] = rect1; } this.m_EventRects = new Rect[rectArray.Length]; for (int index = 0; index < rectArray.Length; ++index) { this.m_EventRects[index] = new Rect(rectArray[index].x + rect.x, rectArray[index].y + rect.y, rectArray[index].width, rectArray[index].height); } if (this.m_EventsSelected == null || this.m_EventsSelected.Length != events.Length || this.m_EventsSelected.Length == 0) { this.m_EventsSelected = new bool[events.Length]; AnimationEventPopup.ClosePopup(); } Vector2 offset = Vector2.zero; int clickedIndex; float startSelect; float endSelect; switch (EditorGUIExt.MultiSelection(rect, positions, new GUIContent(image), rectArray, ref this.m_EventsSelected, (bool[])null, out clickedIndex, out offset, out startSelect, out endSelect, GUIStyle.none)) { case HighLevelEvent.ContextClick: GenericMenu genericMenu = new GenericMenu(); genericMenu.AddItem(new GUIContent("Add Animation Event"), false, new GenericMenu.MenuFunction2(this.EventLineContextMenuAdd), (object)new EventManipulationHandler.EventModificationContextMenuObjet(clipInfo, events[clickedIndex].time, clickedIndex)); genericMenu.AddItem(new GUIContent("Delete Animation Event"), false, new GenericMenu.MenuFunction2(this.EventLineContextMenuDelete), (object)new EventManipulationHandler.EventModificationContextMenuObjet(clipInfo, events[clickedIndex].time, clickedIndex)); genericMenu.ShowAsContext(); this.m_InstantTooltipText = (string)null; break; case HighLevelEvent.BeginDrag: EventManipulationHandler.m_EventsAtMouseDown = events; EventManipulationHandler.m_EventTimes = new float[events.Length]; for (int index = 0; index < events.Length; ++index) { EventManipulationHandler.m_EventTimes[index] = events[index].time; } break; case HighLevelEvent.Drag: for (int index = events.Length - 1; index >= 0; --index) { if (this.m_EventsSelected[index]) { EventManipulationHandler.m_EventsAtMouseDown[index].time = Mathf.Clamp01(EventManipulationHandler.m_EventTimes[index] + offset.x / rect.width); } } int[] numArray1 = new int[this.m_EventsSelected.Length]; for (int index = 0; index < numArray1.Length; ++index) { numArray1[index] = index; } Array.Sort((Array)EventManipulationHandler.m_EventsAtMouseDown, (Array)numArray1, (IComparer) new AnimationEventTimeLine.EventComparer()); bool[] flagArray = (bool[])this.m_EventsSelected.Clone(); float[] numArray2 = (float[])EventManipulationHandler.m_EventTimes.Clone(); for (int index = 0; index < numArray1.Length; ++index) { this.m_EventsSelected[index] = flagArray[numArray1[index]]; EventManipulationHandler.m_EventTimes[index] = numArray2[numArray1[index]]; } events = EventManipulationHandler.m_EventsAtMouseDown; flag = true; break; case HighLevelEvent.Delete: flag = this.DeleteEvents(ref events, this.m_EventsSelected); break; case HighLevelEvent.SelectionChanged: if (clickedIndex >= 0) { AnimationEventPopup.Edit(clipInfo, clickedIndex); break; } AnimationEventPopup.ClosePopup(); break; } this.CheckRectsOnMouseMove(rect, events, rectArray); return(flag); }
public bool HandleEventManipulation(Rect rect, ref AnimationEvent[] events, AnimationClipInfoProperties clipInfo) { Texture image = EditorGUIUtility.IconContent("Animation.EventMarker").image; bool result = false; Rect[] array = new Rect[events.Length]; Rect[] array2 = new Rect[events.Length]; int num = 1; int num2 = 0; for (int i = 0; i < events.Length; i++) { AnimationEvent animationEvent = events[i]; if (num2 == 0) { num = 1; while (i + num < events.Length && events[i + num].time == animationEvent.time) { num++; } num2 = num; } num2--; float num3 = Mathf.Floor(this.m_Timeline.TimeToPixel(animationEvent.time, rect)); int num4 = 0; if (num > 1) { float num5 = (float)Mathf.Min((num - 1) * (image.width - 1), (int)(1f / this.m_Timeline.PixelDeltaToTime(rect) - (float)(image.width * 2))); num4 = Mathf.FloorToInt(Mathf.Max(0f, num5 - (float)((image.width - 1) * num2))); } Rect rect2 = new Rect(num3 + (float)num4 - (float)(image.width / 2), (rect.height - 10f) * (float)(num2 - num + 1) / (float)Mathf.Max(1, num - 1), (float)image.width, (float)image.height); array[i] = rect2; array2[i] = rect2; } this.m_EventRects = new Rect[array.Length]; for (int j = 0; j < array.Length; j++) { this.m_EventRects[j] = new Rect(array[j].x + rect.x, array[j].y + rect.y, array[j].width, array[j].height); } if (this.m_EventsSelected == null || this.m_EventsSelected.Length != events.Length || this.m_EventsSelected.Length == 0) { this.m_EventsSelected = new bool[events.Length]; this.m_Events = null; } Vector2 zero = Vector2.zero; int num6; float num7; float num8; HighLevelEvent highLevelEvent = EditorGUIExt.MultiSelection(rect, array2, new GUIContent(image), array, ref this.m_EventsSelected, null, out num6, out zero, out num7, out num8, GUIStyle.none); if (highLevelEvent != HighLevelEvent.None) { switch (highLevelEvent) { case HighLevelEvent.ContextClick: { int num9 = this.m_EventsSelected.Count((bool selected) => selected); GenericMenu genericMenu = new GenericMenu(); genericMenu.AddItem(new GUIContent("Add Animation Event"), false, new GenericMenu.MenuFunction2(this.EventLineContextMenuAdd), new EventManipulationHandler.EventModificationContextMenuObject(clipInfo, events[num6].time, num6, this.m_EventsSelected)); genericMenu.AddItem(new GUIContent((num9 <= 1) ? "Delete Animation Event" : "Delete Animation Events"), false, new GenericMenu.MenuFunction2(this.EventLineContextMenuDelete), new EventManipulationHandler.EventModificationContextMenuObject(clipInfo, events[num6].time, num6, this.m_EventsSelected)); genericMenu.ShowAsContext(); this.m_InstantTooltipText = null; break; } case HighLevelEvent.BeginDrag: EventManipulationHandler.m_EventsAtMouseDown = events; EventManipulationHandler.m_EventTimes = new float[events.Length]; for (int k = 0; k < events.Length; k++) { EventManipulationHandler.m_EventTimes[k] = events[k].time; } break; case HighLevelEvent.Drag: { for (int l = events.Length - 1; l >= 0; l--) { if (this.m_EventsSelected[l]) { AnimationEvent animationEvent2 = EventManipulationHandler.m_EventsAtMouseDown[l]; animationEvent2.time = Mathf.Clamp01(EventManipulationHandler.m_EventTimes[l] + zero.x / rect.width); } } int[] array3 = new int[this.m_EventsSelected.Length]; for (int m = 0; m < array3.Length; m++) { array3[m] = m; } Array.Sort(EventManipulationHandler.m_EventsAtMouseDown, array3, new AnimationEventTimeLine.EventComparer()); bool[] array4 = (bool[])this.m_EventsSelected.Clone(); float[] array5 = (float[])EventManipulationHandler.m_EventTimes.Clone(); for (int n = 0; n < array3.Length; n++) { this.m_EventsSelected[n] = array4[array3[n]]; EventManipulationHandler.m_EventTimes[n] = array5[array3[n]]; } events = EventManipulationHandler.m_EventsAtMouseDown; result = true; break; } case HighLevelEvent.Delete: result = this.DeleteEvents(ref events, this.m_EventsSelected); break; case HighLevelEvent.SelectionChanged: this.EditEvents(clipInfo, this.m_EventsSelected); break; } } if (Event.current.type == EventType.ContextClick && rect.Contains(Event.current.mousePosition)) { Event.current.Use(); int num10 = this.m_EventsSelected.Count((bool selected) => selected); float time = Mathf.Max(this.m_Timeline.PixelToTime(Event.current.mousePosition.x, rect), 0f); GenericMenu genericMenu2 = new GenericMenu(); genericMenu2.AddItem(new GUIContent("Add Animation Event"), false, new GenericMenu.MenuFunction2(this.EventLineContextMenuAdd), new EventManipulationHandler.EventModificationContextMenuObject(clipInfo, time, -1, this.m_EventsSelected)); if (num10 > 0) { genericMenu2.AddItem(new GUIContent((num10 <= 1) ? "Delete Animation Event" : "Delete Animation Events"), false, new GenericMenu.MenuFunction2(this.EventLineContextMenuDelete), new EventManipulationHandler.EventModificationContextMenuObject(clipInfo, time, -1, this.m_EventsSelected)); } genericMenu2.ShowAsContext(); this.m_InstantTooltipText = null; } this.CheckRectsOnMouseMove(rect, events, array); return(result); }
public void EventLineGUI(Rect rect, AnimationWindowState state) { AnimationClip activeAnimationClip = state.activeAnimationClip; GameObject activeRootGameObject = state.activeRootGameObject; GUI.BeginGroup(rect); Color color = GUI.color; Rect rect2 = new Rect(0f, 0f, rect.width, rect.height); float time = ((float)Mathf.RoundToInt(state.PixelToTime(Event.current.mousePosition.x, rect) * state.frameRate)) / state.frameRate; if (activeAnimationClip != null) { int num8; float num9; float num10; AnimationEvent[] animationEvents = AnimationUtility.GetAnimationEvents(activeAnimationClip); Texture image = EditorGUIUtility.IconContent("Animation.EventMarker").image; Rect[] hitPositions = new Rect[animationEvents.Length]; Rect[] positions = new Rect[animationEvents.Length]; int num2 = 1; int num3 = 0; for (int i = 0; i < animationEvents.Length; i++) { AnimationEvent event2 = animationEvents[i]; if (num3 == 0) { num2 = 1; while (((i + num2) < animationEvents.Length) && (animationEvents[i + num2].time == event2.time)) { num2++; } num3 = num2; } num3--; float num5 = Mathf.Floor(state.FrameToPixel(event2.time * activeAnimationClip.frameRate, rect)); int num6 = 0; if (num2 > 1) { float num7 = Mathf.Min((int)((num2 - 1) * (image.width - 1)), (int)(((int)state.FrameDeltaToPixel(rect)) - (image.width * 2))); num6 = Mathf.FloorToInt(Mathf.Max((float)0f, (float)(num7 - ((image.width - 1) * num3)))); } Rect rect3 = new Rect((num5 + num6) - (image.width / 2), ((rect.height - 10f) * ((num3 - num2) + 1)) / ((float)Mathf.Max(1, num2 - 1)), (float)image.width, (float)image.height); hitPositions[i] = rect3; positions[i] = rect3; } if (this.m_DirtyTooltip) { if ((this.m_HoverEvent >= 0) && (this.m_HoverEvent < hitPositions.Length)) { this.m_InstantTooltipText = AnimationEventPopup.FormatEvent(activeRootGameObject, animationEvents[this.m_HoverEvent]); this.m_InstantTooltipPoint = new Vector2(((hitPositions[this.m_HoverEvent].xMin + ((int)(hitPositions[this.m_HoverEvent].width / 2f))) + rect.x) - 30f, rect.yMax); } this.m_DirtyTooltip = false; } if ((this.m_EventsSelected == null) || (this.m_EventsSelected.Length != animationEvents.Length)) { this.m_EventsSelected = new bool[animationEvents.Length]; AnimationEventPopup.ClosePopup(); } Vector2 zero = Vector2.zero; switch (EditorGUIExt.MultiSelection(rect, positions, new GUIContent(image), hitPositions, ref this.m_EventsSelected, null, out num8, out zero, out num9, out num10, GUIStyle.none)) { case HighLevelEvent.DoubleClick: if (num8 == -1) { this.EventLineContextMenuAdd(new EventLineContextMenuObject(activeRootGameObject, activeAnimationClip, time, -1)); break; } AnimationEventPopup.Edit(activeRootGameObject, state.activeAnimationClip, num8, this.m_Owner); break; case HighLevelEvent.ContextClick: { GenericMenu menu = new GenericMenu(); EventLineContextMenuObject userData = new EventLineContextMenuObject(activeRootGameObject, activeAnimationClip, animationEvents[num8].time, num8); menu.AddItem(new GUIContent("Edit Animation Event"), false, new GenericMenu.MenuFunction2(this.EventLineContextMenuEdit), userData); menu.AddItem(new GUIContent("Add Animation Event"), false, new GenericMenu.MenuFunction2(this.EventLineContextMenuAdd), userData); menu.AddItem(new GUIContent("Delete Animation Event"), false, new GenericMenu.MenuFunction2(this.EventLineContextMenuDelete), userData); menu.ShowAsContext(); this.m_InstantTooltipText = null; this.m_DirtyTooltip = true; state.Repaint(); break; } case HighLevelEvent.BeginDrag: this.m_EventsAtMouseDown = animationEvents; this.m_EventTimes = new float[animationEvents.Length]; for (int j = 0; j < animationEvents.Length; j++) { this.m_EventTimes[j] = animationEvents[j].time; } break; case HighLevelEvent.Drag: { for (int k = animationEvents.Length - 1; k >= 0; k--) { if (this.m_EventsSelected[k]) { AnimationEvent event4 = this.m_EventsAtMouseDown[k]; event4.time = this.m_EventTimes[k] + (zero.x * state.PixelDeltaToTime(rect)); event4.time = Mathf.Max(0f, event4.time); event4.time = ((float)Mathf.RoundToInt(event4.time * activeAnimationClip.frameRate)) / activeAnimationClip.frameRate; } } int[] items = new int[this.m_EventsSelected.Length]; for (int m = 0; m < items.Length; m++) { items[m] = m; } Array.Sort(this.m_EventsAtMouseDown, items, new EventComparer()); bool[] flagArray = (bool[])this.m_EventsSelected.Clone(); float[] numArray2 = (float[])this.m_EventTimes.Clone(); for (int n = 0; n < items.Length; n++) { this.m_EventsSelected[n] = flagArray[items[n]]; this.m_EventTimes[n] = numArray2[items[n]]; } Undo.RegisterCompleteObjectUndo(activeAnimationClip, "Move Event"); AnimationUtility.SetAnimationEvents(activeAnimationClip, this.m_EventsAtMouseDown); this.m_DirtyTooltip = true; break; } case HighLevelEvent.Delete: this.DeleteEvents(activeAnimationClip, this.m_EventsSelected); break; case HighLevelEvent.SelectionChanged: state.ClearKeySelections(); if (num8 != -1) { AnimationEventPopup.UpdateSelection(activeRootGameObject, state.activeAnimationClip, num8, this.m_Owner); } break; } this.CheckRectsOnMouseMove(rect, animationEvents, hitPositions); } if ((Event.current.type == EventType.ContextClick) && rect2.Contains(Event.current.mousePosition)) { Event.current.Use(); GenericMenu menu2 = new GenericMenu(); menu2.AddItem(new GUIContent("Add Animation Event"), false, new GenericMenu.MenuFunction2(this.EventLineContextMenuAdd), new EventLineContextMenuObject(activeRootGameObject, activeAnimationClip, time, -1)); menu2.ShowAsContext(); } GUI.color = color; GUI.EndGroup(); }
public bool HandleEventManipulation(Rect rect, ref AnimationEvent[] events, AnimationClipInfoProperties clipInfo) { int num8; float num9; float num10; Texture image = EditorGUIUtility.IconContent("Animation.EventMarker").image; bool flag = false; Rect[] hitPositions = new Rect[events.Length]; Rect[] positions = new Rect[events.Length]; int num = 1; int num2 = 0; for (int i = 0; i < events.Length; i++) { AnimationEvent event2 = events[i]; if (num2 == 0) { num = 1; while (((i + num) < events.Length) && (events[i + num].time == event2.time)) { num++; } num2 = num; } num2--; float num4 = Mathf.Floor(this.m_Timeline.TimeToPixel(event2.time, rect)); int num5 = 0; if (num > 1) { float num6 = Mathf.Min((int)((num - 1) * (image.width - 1)), (int)(((int)(1f / this.m_Timeline.PixelDeltaToTime(rect))) - (image.width * 2))); num5 = Mathf.FloorToInt(Mathf.Max((float)0f, (float)(num6 - ((image.width - 1) * num2)))); } Rect rect2 = new Rect((num4 + num5) - (image.width / 2), ((rect.height - 10f) * ((num2 - num) + 1)) / ((float)Mathf.Max(1, num - 1)), (float)image.width, (float)image.height); hitPositions[i] = rect2; positions[i] = rect2; } this.m_EventRects = new Rect[hitPositions.Length]; for (int j = 0; j < hitPositions.Length; j++) { this.m_EventRects[j] = new Rect(hitPositions[j].x + rect.x, hitPositions[j].y + rect.y, hitPositions[j].width, hitPositions[j].height); } if (((this.m_EventsSelected == null) || (this.m_EventsSelected.Length != events.Length)) || (this.m_EventsSelected.Length == 0)) { this.m_EventsSelected = new bool[events.Length]; this.m_Event = null; } Vector2 zero = Vector2.zero; switch (EditorGUIExt.MultiSelection(rect, positions, new GUIContent(image), hitPositions, ref this.m_EventsSelected, null, out num8, out zero, out num9, out num10, GUIStyle.none)) { case HighLevelEvent.ContextClick: { GenericMenu menu = new GenericMenu(); menu.AddItem(new GUIContent("Add Animation Event"), false, new GenericMenu.MenuFunction2(this.EventLineContextMenuAdd), new EventModificationContextMenuObjet(clipInfo, events[num8].time, num8)); menu.AddItem(new GUIContent("Delete Animation Event"), false, new GenericMenu.MenuFunction2(this.EventLineContextMenuDelete), new EventModificationContextMenuObjet(clipInfo, events[num8].time, num8)); menu.ShowAsContext(); this.m_InstantTooltipText = null; break; } case HighLevelEvent.BeginDrag: m_EventsAtMouseDown = events; m_EventTimes = new float[events.Length]; for (int k = 0; k < events.Length; k++) { m_EventTimes[k] = events[k].time; } break; case HighLevelEvent.Drag: { for (int m = events.Length - 1; m >= 0; m--) { if (this.m_EventsSelected[m]) { AnimationEvent event4 = m_EventsAtMouseDown[m]; event4.time = Mathf.Clamp01(m_EventTimes[m] + (zero.x / rect.width)); } } int[] items = new int[this.m_EventsSelected.Length]; for (int n = 0; n < items.Length; n++) { items[n] = n; } Array.Sort(m_EventsAtMouseDown, items, new AnimationEventTimeLine.EventComparer()); bool[] flagArray = (bool[])this.m_EventsSelected.Clone(); float[] numArray2 = (float[])m_EventTimes.Clone(); for (int num14 = 0; num14 < items.Length; num14++) { this.m_EventsSelected[num14] = flagArray[items[num14]]; m_EventTimes[num14] = numArray2[items[num14]]; } events = m_EventsAtMouseDown; flag = true; break; } case HighLevelEvent.Delete: flag = this.DeleteEvents(ref events, this.m_EventsSelected); break; case HighLevelEvent.SelectionChanged: this.m_Event = (num8 < 0) ? null : AnimationWindowEvent.Edit(clipInfo, num8); break; } this.CheckRectsOnMouseMove(rect, events, hitPositions); return(flag); }
private void SliderGUI() { if (this.m_HSlider || this.m_VSlider) { using (new EditorGUI.DisabledScope(!this.enableMouseInput)) { float num; float num2; Bounds drawingBounds = this.drawingBounds; Rect shownAreaInsideMargins = this.shownAreaInsideMargins; float num3 = this.styles.sliderWidth - this.styles.visualSliderWidth; float num4 = (!this.vSlider || !this.hSlider) ? 0f : num3; Vector2 scale = this.m_Scale; if (this.m_HSlider) { Rect position = new Rect(this.drawRect.x + 1f, this.drawRect.yMax - num3, this.drawRect.width - num4, this.styles.sliderWidth); float width = shownAreaInsideMargins.width; float xMin = shownAreaInsideMargins.xMin; if (this.m_EnableSliderZoom) { EditorGUIExt.MinMaxScroller(position, this.horizontalScrollbarID, ref xMin, ref width, drawingBounds.min.x, drawingBounds.max.x, float.NegativeInfinity, float.PositiveInfinity, this.styles.horizontalScrollbar, this.styles.horizontalMinMaxScrollbarThumb, this.styles.horizontalScrollbarLeftButton, this.styles.horizontalScrollbarRightButton, true); } else { xMin = GUI.Scroller(position, xMin, width, drawingBounds.min.x, drawingBounds.max.x, this.styles.horizontalScrollbar, this.styles.horizontalMinMaxScrollbarThumb, this.styles.horizontalScrollbarLeftButton, this.styles.horizontalScrollbarRightButton, true); } num = xMin; num2 = xMin + width; if (num > shownAreaInsideMargins.xMin) { num = Mathf.Min(num, num2 - (this.rect.width / this.m_HScaleMax)); } if (num2 < shownAreaInsideMargins.xMax) { num2 = Mathf.Max(num2, num + (this.rect.width / this.m_HScaleMax)); } this.SetShownHRangeInsideMargins(num, num2); } if (this.m_VSlider) { if (this.m_UpDirection == YDirection.Positive) { Rect rect8 = new Rect(this.drawRect.xMax - num3, this.drawRect.y, this.styles.sliderWidth, this.drawRect.height - num4); float height = shownAreaInsideMargins.height; float num8 = -shownAreaInsideMargins.yMax; if (this.m_EnableSliderZoom) { EditorGUIExt.MinMaxScroller(rect8, this.verticalScrollbarID, ref num8, ref height, -drawingBounds.max.y, -drawingBounds.min.y, float.NegativeInfinity, float.PositiveInfinity, this.styles.verticalScrollbar, this.styles.verticalMinMaxScrollbarThumb, this.styles.verticalScrollbarUpButton, this.styles.verticalScrollbarDownButton, false); } else { num8 = GUI.Scroller(rect8, num8, height, -drawingBounds.max.y, -drawingBounds.min.y, this.styles.verticalScrollbar, this.styles.verticalMinMaxScrollbarThumb, this.styles.verticalScrollbarUpButton, this.styles.verticalScrollbarDownButton, false); } num = -(num8 + height); num2 = -num8; if (num > shownAreaInsideMargins.yMin) { num = Mathf.Min(num, num2 - (this.rect.height / this.m_VScaleMax)); } if (num2 < shownAreaInsideMargins.yMax) { num2 = Mathf.Max(num2, num + (this.rect.height / this.m_VScaleMax)); } this.SetShownVRangeInsideMargins(num, num2); } else { Rect rect14 = new Rect(this.drawRect.xMax - num3, this.drawRect.y, this.styles.sliderWidth, this.drawRect.height - num4); float size = shownAreaInsideMargins.height; float yMin = shownAreaInsideMargins.yMin; if (this.m_EnableSliderZoom) { EditorGUIExt.MinMaxScroller(rect14, this.verticalScrollbarID, ref yMin, ref size, drawingBounds.min.y, drawingBounds.max.y, float.NegativeInfinity, float.PositiveInfinity, this.styles.verticalScrollbar, this.styles.verticalMinMaxScrollbarThumb, this.styles.verticalScrollbarUpButton, this.styles.verticalScrollbarDownButton, false); } else { yMin = GUI.Scroller(rect14, yMin, size, drawingBounds.min.y, drawingBounds.max.y, this.styles.verticalScrollbar, this.styles.verticalMinMaxScrollbarThumb, this.styles.verticalScrollbarUpButton, this.styles.verticalScrollbarDownButton, false); } num = yMin; num2 = yMin + size; if (num > shownAreaInsideMargins.yMin) { num = Mathf.Min(num, num2 - (this.rect.height / this.m_VScaleMax)); } if (num2 < shownAreaInsideMargins.yMax) { num2 = Mathf.Max(num2, num + (this.rect.height / this.m_VScaleMax)); } this.SetShownVRangeInsideMargins(num, num2); } } if (this.uniformScale) { float num11 = this.drawRect.width / this.drawRect.height; scale -= this.m_Scale; Vector2 vector14 = new Vector2(-scale.y * num11, -scale.x / num11); this.m_Scale -= vector14; this.m_Translation.x -= scale.y / 2f; this.m_Translation.y -= scale.x / 2f; this.EnforceScaleAndRange(); } } } }
public void EventLineGUI(Rect rect, AnimationWindowState state) { AnimationClip activeAnimationClip = state.activeAnimationClip; GameObject activeRootGameObject = state.activeRootGameObject; GUI.BeginGroup(rect); Color color = GUI.color; Rect rect1 = new Rect(0.0f, 0.0f, rect.width, rect.height); float time = (float)Mathf.RoundToInt(state.PixelToTime(Event.current.mousePosition.x, rect) * state.frameRate) / state.frameRate; if ((UnityEngine.Object)activeAnimationClip != (UnityEngine.Object)null) { AnimationEvent[] animationEvents = AnimationUtility.GetAnimationEvents(activeAnimationClip); Texture image = EditorGUIUtility.IconContent("Animation.EventMarker").image; Rect[] rectArray = new Rect[animationEvents.Length]; Rect[] positions = new Rect[animationEvents.Length]; int num1 = 1; int num2 = 0; for (int index = 0; index < animationEvents.Length; ++index) { AnimationEvent animationEvent = animationEvents[index]; if (num2 == 0) { num1 = 1; while (index + num1 < animationEvents.Length && (double)animationEvents[index + num1].time == (double)animationEvent.time) { ++num1; } num2 = num1; } --num2; float num3 = Mathf.Floor(state.FrameToPixel(animationEvent.time * activeAnimationClip.frameRate, rect)); int num4 = 0; if (num1 > 1) { num4 = Mathf.FloorToInt(Mathf.Max(0.0f, (float)Mathf.Min((num1 - 1) * (image.width - 1), (int)((double)state.FrameDeltaToPixel(rect) - (double)(image.width * 2))) - (float)((image.width - 1) * num2))); } Rect rect2 = new Rect(num3 + (float)num4 - (float)(image.width / 2), (rect.height - 10f) * (float)(num2 - num1 + 1) / (float)Mathf.Max(1, num1 - 1), (float)image.width, (float)image.height); rectArray[index] = rect2; positions[index] = rect2; } if (this.m_DirtyTooltip) { if (this.m_HoverEvent >= 0 && this.m_HoverEvent < rectArray.Length) { this.m_InstantTooltipText = AnimationEventPopup.FormatEvent(activeRootGameObject, animationEvents[this.m_HoverEvent]); this.m_InstantTooltipPoint = new Vector2((float)((double)rectArray[this.m_HoverEvent].xMin + (double)(int)((double)rectArray[this.m_HoverEvent].width / 2.0) + (double)rect.x - 30.0), rect.yMax); } this.m_DirtyTooltip = false; } if (this.m_EventsSelected == null || this.m_EventsSelected.Length != animationEvents.Length) { this.m_EventsSelected = new bool[animationEvents.Length]; AnimationEventPopup.ClosePopup(); } Vector2 offset = Vector2.zero; int clickedIndex; float startSelect; float endSelect; switch (EditorGUIExt.MultiSelection(rect, positions, new GUIContent(image), rectArray, ref this.m_EventsSelected, (bool[])null, out clickedIndex, out offset, out startSelect, out endSelect, GUIStyle.none)) { case HighLevelEvent.DoubleClick: if (clickedIndex != -1) { AnimationEventPopup.Edit(activeRootGameObject, state.activeAnimationClip, clickedIndex, this.m_Owner); break; } this.EventLineContextMenuAdd((object)new AnimationEventTimeLine.EventLineContextMenuObject(activeRootGameObject, activeAnimationClip, time, -1)); break; case HighLevelEvent.ContextClick: GenericMenu genericMenu = new GenericMenu(); AnimationEventTimeLine.EventLineContextMenuObject contextMenuObject = new AnimationEventTimeLine.EventLineContextMenuObject(activeRootGameObject, activeAnimationClip, animationEvents[clickedIndex].time, clickedIndex); genericMenu.AddItem(new GUIContent("Edit Animation Event"), false, new GenericMenu.MenuFunction2(this.EventLineContextMenuEdit), (object)contextMenuObject); genericMenu.AddItem(new GUIContent("Add Animation Event"), false, new GenericMenu.MenuFunction2(this.EventLineContextMenuAdd), (object)contextMenuObject); genericMenu.AddItem(new GUIContent("Delete Animation Event"), false, new GenericMenu.MenuFunction2(this.EventLineContextMenuDelete), (object)contextMenuObject); genericMenu.ShowAsContext(); this.m_InstantTooltipText = (string)null; this.m_DirtyTooltip = true; state.Repaint(); break; case HighLevelEvent.BeginDrag: this.m_EventsAtMouseDown = animationEvents; this.m_EventTimes = new float[animationEvents.Length]; for (int index = 0; index < animationEvents.Length; ++index) { this.m_EventTimes[index] = animationEvents[index].time; } break; case HighLevelEvent.Drag: for (int index = animationEvents.Length - 1; index >= 0; --index) { if (this.m_EventsSelected[index]) { AnimationEvent animationEvent = this.m_EventsAtMouseDown[index]; animationEvent.time = this.m_EventTimes[index] + offset.x * state.PixelDeltaToTime(rect); animationEvent.time = Mathf.Max(0.0f, animationEvent.time); animationEvent.time = (float)Mathf.RoundToInt(animationEvent.time * activeAnimationClip.frameRate) / activeAnimationClip.frameRate; } } int[] numArray1 = new int[this.m_EventsSelected.Length]; for (int index = 0; index < numArray1.Length; ++index) { numArray1[index] = index; } Array.Sort((Array)this.m_EventsAtMouseDown, (Array)numArray1, (IComparer) new AnimationEventTimeLine.EventComparer()); bool[] flagArray = (bool[])this.m_EventsSelected.Clone(); float[] numArray2 = (float[])this.m_EventTimes.Clone(); for (int index = 0; index < numArray1.Length; ++index) { this.m_EventsSelected[index] = flagArray[numArray1[index]]; this.m_EventTimes[index] = numArray2[numArray1[index]]; } Undo.RegisterCompleteObjectUndo((UnityEngine.Object)activeAnimationClip, "Move Event"); AnimationUtility.SetAnimationEvents(activeAnimationClip, this.m_EventsAtMouseDown); this.m_DirtyTooltip = true; break; case HighLevelEvent.Delete: this.DeleteEvents(activeAnimationClip, this.m_EventsSelected); break; case HighLevelEvent.SelectionChanged: state.ClearKeySelections(); if (clickedIndex != -1) { AnimationEventPopup.UpdateSelection(activeRootGameObject, state.activeAnimationClip, clickedIndex, this.m_Owner); break; } break; } this.CheckRectsOnMouseMove(rect, animationEvents, rectArray); } if (Event.current.type == EventType.ContextClick && rect1.Contains(Event.current.mousePosition)) { Event.current.Use(); GenericMenu genericMenu = new GenericMenu(); genericMenu.AddItem(new GUIContent("Add Animation Event"), false, new GenericMenu.MenuFunction2(this.EventLineContextMenuAdd), (object)new AnimationEventTimeLine.EventLineContextMenuObject(activeRootGameObject, activeAnimationClip, time, -1)); genericMenu.ShowAsContext(); } GUI.color = color; GUI.EndGroup(); }
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(); }
void SliderGUI() { if (!m_HSlider && !m_VSlider) { return; } using (new EditorGUI.DisabledScope(!enableMouseInput)) { Bounds editorBounds = drawingBounds; Rect area = shownAreaInsideMargins; float min, max; float inset = styles.sliderWidth - styles.visualSliderWidth; float otherInset = (vSlider && hSlider) ? inset : 0; Vector2 scaleDelta = m_Scale; // Horizontal range slider if (m_HSlider) { Rect hRangeSliderRect = new Rect(drawRect.x + 1, drawRect.yMax - inset, drawRect.width - otherInset, styles.sliderWidth); float shownXRange = area.width; float shownXMin = area.xMin; if (allowSliderZoomHorizontal) { EditorGUIExt.MinMaxScroller(hRangeSliderRect, horizontalScrollbarID, ref shownXMin, ref shownXRange, editorBounds.min.x, editorBounds.max.x, Mathf.NegativeInfinity, Mathf.Infinity, styles.horizontalScrollbar, styles.horizontalMinMaxScrollbarThumb, styles.horizontalScrollbarLeftButton, styles.horizontalScrollbarRightButton, true); } else { shownXMin = GUI.Scroller(hRangeSliderRect, shownXMin, shownXRange, editorBounds.min.x, editorBounds.max.x, styles.horizontalScrollbar, styles.horizontalMinMaxScrollbarThumb, styles.horizontalScrollbarLeftButton, styles.horizontalScrollbarRightButton, true); } min = shownXMin; max = shownXMin + shownXRange; if (min > area.xMin) { min = Mathf.Min(min, max - rect.width / m_HScaleMax); } if (max < area.xMax) { max = Mathf.Max(max, min + rect.width / m_HScaleMax); } SetShownHRangeInsideMargins(min, max); } // Vertical range slider // Reverse y values since y increses upwards for the draw area but downwards for the slider if (m_VSlider) { if (m_UpDirection == YDirection.Positive) { Rect vRangeSliderRect = new Rect(drawRect.xMax - inset, drawRect.y, styles.sliderWidth, drawRect.height - otherInset); float shownYRange = area.height; float shownYMin = -area.yMax; if (allowSliderZoomVertical) { EditorGUIExt.MinMaxScroller(vRangeSliderRect, verticalScrollbarID, ref shownYMin, ref shownYRange, -editorBounds.max.y, -editorBounds.min.y, Mathf.NegativeInfinity, Mathf.Infinity, styles.verticalScrollbar, styles.verticalMinMaxScrollbarThumb, styles.verticalScrollbarUpButton, styles.verticalScrollbarDownButton, false); } else { shownYMin = GUI.Scroller(vRangeSliderRect, shownYMin, shownYRange, -editorBounds.max.y, -editorBounds.min.y, styles.verticalScrollbar, styles.verticalMinMaxScrollbarThumb, styles.verticalScrollbarUpButton, styles.verticalScrollbarDownButton, false); } min = -(shownYMin + shownYRange); max = -shownYMin; if (min > area.yMin) { min = Mathf.Min(min, max - rect.height / m_VScaleMax); } if (max < area.yMax) { max = Mathf.Max(max, min + rect.height / m_VScaleMax); } SetShownVRangeInsideMargins(min, max); } else { Rect vRangeSliderRect = new Rect(drawRect.xMax - inset, drawRect.y, styles.sliderWidth, drawRect.height - otherInset); float shownYRange = area.height; float shownYMin = area.yMin; if (allowSliderZoomVertical) { EditorGUIExt.MinMaxScroller(vRangeSliderRect, verticalScrollbarID, ref shownYMin, ref shownYRange, editorBounds.min.y, editorBounds.max.y, Mathf.NegativeInfinity, Mathf.Infinity, styles.verticalScrollbar, styles.verticalMinMaxScrollbarThumb, styles.verticalScrollbarUpButton, styles.verticalScrollbarDownButton, false); } else { shownYMin = GUI.Scroller(vRangeSliderRect, shownYMin, shownYRange, editorBounds.min.y, editorBounds.max.y, styles.verticalScrollbar, styles.verticalMinMaxScrollbarThumb, styles.verticalScrollbarUpButton, styles.verticalScrollbarDownButton, false); } min = shownYMin; max = shownYMin + shownYRange; if (min > area.yMin) { min = Mathf.Min(min, max - rect.height / m_VScaleMax); } if (max < area.yMax) { max = Mathf.Max(max, min + rect.height / m_VScaleMax); } SetShownVRangeInsideMargins(min, max); } } if (uniformScale) { float aspect = drawRect.width / drawRect.height; scaleDelta -= m_Scale; var delta = new Vector2(-scaleDelta.y * aspect, -scaleDelta.x / aspect); m_Scale -= delta; m_Translation.x -= scaleDelta.y / 2; m_Translation.y -= scaleDelta.x / 2; EnforceScaleAndRange(); } } }
public void EventLineGUI(Rect rect, AnimationWindowState state) { AnimationClip activeAnimationClip = state.activeAnimationClip; GameObject activeRootGameObject = state.activeRootGameObject; if (activeRootGameObject == null) { return; } GUI.BeginGroup(rect); Color color = GUI.color; Rect rect2 = new Rect(0f, 0f, rect.width, rect.height); float time = Mathf.Max((float)Mathf.RoundToInt(state.PixelToTime(Event.current.mousePosition.x, rect) * state.frameRate) / state.frameRate, 0f); if (activeAnimationClip != null) { AnimationEvent[] animationEvents = AnimationUtility.GetAnimationEvents(activeAnimationClip); Texture image = EditorGUIUtility.IconContent("Animation.EventMarker").image; Rect[] array = new Rect[animationEvents.Length]; Rect[] array2 = new Rect[animationEvents.Length]; int num = 1; int num2 = 0; for (int i = 0; i < animationEvents.Length; i++) { AnimationEvent animationEvent = animationEvents[i]; if (num2 == 0) { num = 1; while (i + num < animationEvents.Length && animationEvents[i + num].time == animationEvent.time) { num++; } num2 = num; } num2--; float num3 = Mathf.Floor(state.FrameToPixel(animationEvent.time * activeAnimationClip.frameRate, rect)); int num4 = 0; if (num > 1) { float num5 = (float)Mathf.Min((num - 1) * (image.width - 1), (int)(state.FrameDeltaToPixel(rect) - (float)(image.width * 2))); num4 = Mathf.FloorToInt(Mathf.Max(0f, num5 - (float)((image.width - 1) * num2))); } Rect rect3 = new Rect(num3 + (float)num4 - (float)(image.width / 2), (rect.height - 10f) * (float)(num2 - num + 1) / (float)Mathf.Max(1, num - 1), (float)image.width, (float)image.height); array[i] = rect3; array2[i] = rect3; } if (this.m_DirtyTooltip) { if (this.m_HoverEvent >= 0 && this.m_HoverEvent < array.Length) { this.m_InstantTooltipText = AnimationEventPopup.FormatEvent(activeRootGameObject, animationEvents[this.m_HoverEvent]); this.m_InstantTooltipPoint = new Vector2(array[this.m_HoverEvent].xMin + (float)((int)(array[this.m_HoverEvent].width / 2f)) + rect.x - 30f, rect.yMax); } this.m_DirtyTooltip = false; } if (this.m_EventsSelected == null || this.m_EventsSelected.Length != animationEvents.Length) { this.m_EventsSelected = new bool[animationEvents.Length]; AnimationEventPopup.ClosePopup(); } Vector2 zero = Vector2.zero; int num6; float num7; float num8; HighLevelEvent highLevelEvent = EditorGUIExt.MultiSelection(rect, array2, new GUIContent(image), array, ref this.m_EventsSelected, null, out num6, out zero, out num7, out num8, GUIStyle.none); if (highLevelEvent != HighLevelEvent.None) { switch (highLevelEvent) { case HighLevelEvent.DoubleClick: if (num6 != -1) { AnimationEventPopup.Edit(activeRootGameObject, state.activeAnimationClip, num6, this.m_Owner); } else { this.EventLineContextMenuAdd(new AnimationEventTimeLine.EventLineContextMenuObject(activeRootGameObject, activeAnimationClip, time, -1)); } break; case HighLevelEvent.ContextClick: { GenericMenu genericMenu = new GenericMenu(); AnimationEventTimeLine.EventLineContextMenuObject userData = new AnimationEventTimeLine.EventLineContextMenuObject(activeRootGameObject, activeAnimationClip, animationEvents[num6].time, num6); genericMenu.AddItem(new GUIContent("Edit Animation Event"), false, new GenericMenu.MenuFunction2(this.EventLineContextMenuEdit), userData); genericMenu.AddItem(new GUIContent("Add Animation Event"), false, new GenericMenu.MenuFunction2(this.EventLineContextMenuAdd), userData); genericMenu.AddItem(new GUIContent("Delete Animation Event"), false, new GenericMenu.MenuFunction2(this.EventLineContextMenuDelete), userData); genericMenu.ShowAsContext(); this.m_InstantTooltipText = null; this.m_DirtyTooltip = true; state.Repaint(); break; } case HighLevelEvent.BeginDrag: this.m_EventsAtMouseDown = animationEvents; this.m_EventTimes = new float[animationEvents.Length]; for (int j = 0; j < animationEvents.Length; j++) { this.m_EventTimes[j] = animationEvents[j].time; } break; case HighLevelEvent.Drag: { for (int k = animationEvents.Length - 1; k >= 0; k--) { if (this.m_EventsSelected[k]) { AnimationEvent animationEvent2 = this.m_EventsAtMouseDown[k]; animationEvent2.time = this.m_EventTimes[k] + zero.x * state.PixelDeltaToTime(rect); animationEvent2.time = Mathf.Max(0f, animationEvent2.time); animationEvent2.time = (float)Mathf.RoundToInt(animationEvent2.time * activeAnimationClip.frameRate) / activeAnimationClip.frameRate; } } int[] array3 = new int[this.m_EventsSelected.Length]; for (int l = 0; l < array3.Length; l++) { array3[l] = l; } Array.Sort(this.m_EventsAtMouseDown, array3, new AnimationEventTimeLine.EventComparer()); bool[] array4 = (bool[])this.m_EventsSelected.Clone(); float[] array5 = (float[])this.m_EventTimes.Clone(); for (int m = 0; m < array3.Length; m++) { this.m_EventsSelected[m] = array4[array3[m]]; this.m_EventTimes[m] = array5[array3[m]]; } Undo.RegisterCompleteObjectUndo(activeAnimationClip, "Move Event"); AnimationUtility.SetAnimationEvents(activeAnimationClip, this.m_EventsAtMouseDown); this.m_DirtyTooltip = true; break; } case HighLevelEvent.Delete: this.DeleteEvents(activeAnimationClip, this.m_EventsSelected); break; case HighLevelEvent.SelectionChanged: state.ClearKeySelections(); if (num6 != -1) { AnimationEventPopup.UpdateSelection(activeRootGameObject, state.activeAnimationClip, num6, this.m_Owner); } break; } } this.CheckRectsOnMouseMove(rect, animationEvents, array); } if (Event.current.type == EventType.ContextClick && rect2.Contains(Event.current.mousePosition)) { Event.current.Use(); GenericMenu genericMenu2 = new GenericMenu(); genericMenu2.AddItem(new GUIContent("Add Animation Event"), false, new GenericMenu.MenuFunction2(this.EventLineContextMenuAdd), new AnimationEventTimeLine.EventLineContextMenuObject(activeRootGameObject, activeAnimationClip, time, -1)); genericMenu2.ShowAsContext(); } GUI.color = color; GUI.EndGroup(); }
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 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(); }
public static void MinMaxSlider(Rect position, ref float value, ref float size, float visualStart, float visualEnd, float startLimit, float endLimit, GUIStyle slider, GUIStyle thumb, bool horiz) { EditorGUIExt.DoMinMaxSlider(position, GUIUtility.GetControlID(EditorGUIExt.s_MinMaxSliderHash, FocusType.Passive), ref value, ref size, visualStart, visualEnd, startLimit, endLimit, slider, thumb, horiz); }
public void EventLineGUI(Rect rect, AnimationWindowState state) { // We only display and manipulate animation events from the main // game object in selection. If we ever want to update to handle // a multiple selection, a single timeline might not be sufficient... AnimationClip clip = state.activeAnimationClip; GameObject animated = state.activeRootGameObject; GUI.BeginGroup(rect); Color backupCol = GUI.color; Rect eventLineRect = new Rect(0, 0, rect.width, rect.height); float mousePosTime = Mathf.Max(Mathf.RoundToInt(state.PixelToTime(Event.current.mousePosition.x, rect) * state.frameRate) / state.frameRate, 0.0f); // Draw events if (clip != null) { AnimationEvent[] events = AnimationUtility.GetAnimationEvents(clip); Texture eventMarker = EditorGUIUtility.IconContent("Animation.EventMarker").image; // Calculate rects Rect[] hitRects = new Rect[events.Length]; Rect[] drawRects = new Rect[events.Length]; int shared = 1; int sharedLeft = 0; for (int i = 0; i < events.Length; i++) { AnimationEvent evt = events[i]; if (sharedLeft == 0) { shared = 1; while (i + shared < events.Length && events[i + shared].time == evt.time) { shared++; } sharedLeft = shared; } sharedLeft--; // Important to take floor of positions of GUI stuff to get pixel correct alignment of // stuff drawn with both GUI and Handles/GL. Otherwise things are off by one pixel half the time. float keypos = Mathf.Floor(state.FrameToPixel(evt.time * clip.frameRate, rect)); int sharedOffset = 0; if (shared > 1) { float spread = Mathf.Min((shared - 1) * (eventMarker.width - 1), (int)(state.FrameDeltaToPixel(rect) - eventMarker.width * 2)); sharedOffset = Mathf.FloorToInt(Mathf.Max(0, spread - (eventMarker.width - 1) * (sharedLeft))); } Rect r = new Rect( keypos + sharedOffset - eventMarker.width / 2, (rect.height - 10) * (float)(sharedLeft - shared + 1) / Mathf.Max(1, shared - 1), eventMarker.width, eventMarker.height); hitRects[i] = r; drawRects[i] = r; } // Store tooptip info if (m_DirtyTooltip) { if (m_HoverEvent >= 0 && m_HoverEvent < hitRects.Length) { m_InstantTooltipText = AnimationWindowEventInspector.FormatEvent(animated, events[m_HoverEvent]); m_InstantTooltipPoint = new Vector2(hitRects[m_HoverEvent].xMin + (int)(hitRects[m_HoverEvent].width / 2) + rect.x - 30, rect.yMax); } m_DirtyTooltip = false; } bool[] selectedEvents = new bool[events.Length]; Object[] selectedObjects = Selection.objects; foreach (Object selectedObject in selectedObjects) { AnimationWindowEvent awe = selectedObject as AnimationWindowEvent; if (awe != null) { if (awe.eventIndex >= 0 && awe.eventIndex < selectedEvents.Length) { selectedEvents[awe.eventIndex] = true; } } } Vector2 offset = Vector2.zero; int clickedIndex; float startSelection, endSelection; // TODO: GUIStyle.none has hopping margins that need to be fixed HighLevelEvent hEvent = EditorGUIExt.MultiSelection( rect, drawRects, new GUIContent(eventMarker), hitRects, ref selectedEvents, null, out clickedIndex, out offset, out startSelection, out endSelection, GUIStyle.none ); if (hEvent != HighLevelEvent.None) { switch (hEvent) { case HighLevelEvent.BeginDrag: m_EventsAtMouseDown = events; m_EventTimes = new float[events.Length]; for (int i = 0; i < events.Length; i++) { m_EventTimes[i] = events[i].time; } break; case HighLevelEvent.SelectionChanged: state.ClearKeySelections(); EditEvents(animated, clip, selectedEvents); break; case HighLevelEvent.Delete: DeleteEvents(clip, selectedEvents); break; case HighLevelEvent.DoubleClick: if (clickedIndex != -1) { EditEvents(animated, clip, selectedEvents); } else { EventLineContextMenuAdd(new EventLineContextMenuObject(animated, clip, mousePosTime, -1, selectedEvents)); } break; case HighLevelEvent.Drag: for (int i = events.Length - 1; i >= 0; i--) { if (selectedEvents[i]) { AnimationEvent evt = m_EventsAtMouseDown[i]; evt.time = m_EventTimes[i] + offset.x * state.PixelDeltaToTime(rect); evt.time = Mathf.Max(0.0F, evt.time); evt.time = Mathf.RoundToInt(evt.time * clip.frameRate) / clip.frameRate; } } int[] order = new int[selectedEvents.Length]; for (int i = 0; i < order.Length; i++) { order[i] = i; } System.Array.Sort(m_EventsAtMouseDown, order, new EventComparer()); bool[] selectedOld = (bool[])selectedEvents.Clone(); float[] timesOld = (float[])m_EventTimes.Clone(); for (int i = 0; i < order.Length; i++) { selectedEvents[i] = selectedOld[order[i]]; m_EventTimes[i] = timesOld[order[i]]; } // Update selection to reflect new order. EditEvents(animated, clip, selectedEvents); Undo.RegisterCompleteObjectUndo(clip, "Move Event"); AnimationUtility.SetAnimationEvents(clip, m_EventsAtMouseDown); m_DirtyTooltip = true; break; case HighLevelEvent.ContextClick: GenericMenu menu = new GenericMenu(); var contextData = new EventLineContextMenuObject(animated, clip, events[clickedIndex].time, clickedIndex, selectedEvents); int selectedEventsCount = selectedEvents.Count(selected => selected); menu.AddItem( EditorGUIUtility.TrTextContent("Add Animation Event"), false, EventLineContextMenuAdd, contextData); menu.AddItem( new GUIContent(selectedEventsCount > 1 ? "Delete Animation Events" : "Delete Animation Event"), false, EventLineContextMenuDelete, contextData); menu.ShowAsContext(); // Mouse may move while context menu is open - make sure instant tooltip is handled m_InstantTooltipText = null; m_DirtyTooltip = true; state.Repaint(); break; } } CheckRectsOnMouseMove(rect, events, hitRects); // Create context menu on context click if (Event.current.type == EventType.ContextClick && eventLineRect.Contains(Event.current.mousePosition)) { Event.current.Use(); // Create menu GenericMenu menu = new GenericMenu(); var contextData = new EventLineContextMenuObject(animated, clip, mousePosTime, -1, selectedEvents); int selectedEventsCount = selectedEvents.Count(selected => selected); menu.AddItem( EditorGUIUtility.TrTextContent("Add Animation Event"), false, EventLineContextMenuAdd, contextData); if (selectedEventsCount > 0) { menu.AddItem( new GUIContent(selectedEventsCount > 1 ? "Delete Animation Events" : "Delete Animation Event"), false, EventLineContextMenuDelete, contextData); } menu.ShowAsContext(); } } GUI.color = backupCol; GUI.EndGroup(); }
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(); }