/// Move the selected points using standard handles. returns true if point moved public static bool MovePoints(IEditablePoint points, Transform cloudTransform, List <int> selection) { if (selection.Count == 0) { return(false); } // Editing for the case where we're in a 3D sceneview if (Camera.current) { var handlePos = Vector3.zero; handlePos = Tools.pivotMode == PivotMode.Pivot ? points.GetPosition(selection[0]) : selection.Aggregate(handlePos, (current, index) => current + points.GetPosition(index)) / selection.Count; handlePos = cloudTransform.TransformPoint(handlePos); var newPos = Handles.PositionHandle(handlePos, Tools.pivotRotation == PivotRotation.Local ? cloudTransform.rotation : Quaternion.identity); if (GUI.changed) { Vector3 delta = cloudTransform.InverseTransformPoint(newPos) - cloudTransform.InverseTransformPoint(handlePos); foreach (int i in selection) { points.SetPosition(i, points.GetPosition(i) + delta); } return(true); } } return(false); }
public static int FindNearest(Vector2 point, Transform cloudTransform, IEditablePoint points) { Ray ray = HandleUtility.GUIPointToWorldRay(point); Dictionary <int, float> dictionary = new Dictionary <int, float>(); for (int i = 0; i < points.Count; i++) { float num = 0f; Vector3 zero = Vector3.zero; if (MathUtils.IntersectRaySphere(ray, cloudTransform.TransformPoint(points.GetPosition(i)), points.GetPointScale() * 0.5f, ref num, ref zero)) { if (num > 0f) { dictionary.Add(i, num); } } } int result; if (dictionary.Count <= 0) { result = -1; } else { IOrderedEnumerable <KeyValuePair <int, float> > source = from x in dictionary orderby x.Value select x; result = source.First <KeyValuePair <int, float> >().Key; } return(result); }
public static bool MovePoints(IEditablePoint points, Transform cloudTransform, List <int> selection) { bool result; if (selection.Count == 0) { result = false; } else { if (Camera.current) { Vector3 vector = Vector3.zero; vector = ((Tools.pivotMode != PivotMode.Pivot) ? (selection.Aggregate(vector, (Vector3 current, int index) => current + points.GetPosition(index)) / (float)selection.Count) : points.GetPosition(selection[0])); vector = cloudTransform.TransformPoint(vector); Vector3 position = Handles.PositionHandle(vector, (Tools.pivotRotation != PivotRotation.Local) ? Quaternion.identity : cloudTransform.rotation); if (GUI.changed) { Vector3 b = cloudTransform.InverseTransformPoint(position) - cloudTransform.InverseTransformPoint(vector); foreach (int current2 in selection) { points.SetPosition(current2, points.GetPosition(current2) + b); } result = true; return(result); } } result = false; } return(result); }
public static int FindNearest(Vector2 point, Transform cloudTransform, IEditablePoint points) { var r = HandleUtility.GUIPointToWorldRay(point); var found = new Dictionary <int, float>(); for (var i = 0; i < points.Count; i++) { float distance = 0; Vector3 collisionPoint = Vector3.zero; if (MathUtils.IntersectRaySphere(r, cloudTransform.TransformPoint(points.GetPosition(i)), points.GetPointScale() * 0.5f, ref distance, ref collisionPoint)) { //Only care if we start outside a probe if (distance > 0) { found.Add(i, distance); } } } if (found.Count <= 0) { return(-1); } var sorted = found.OrderBy(x => x.Value); return(sorted.First().Key); }
public static int FindNearest(Vector2 point, Transform cloudTransform, IEditablePoint points) { Ray ray = HandleUtility.GUIPointToWorldRay(point); Dictionary <int, float> source = new Dictionary <int, float>(); for (int i = 0; i < points.Count; i++) { float t = 0f; Vector3 zero = Vector3.zero; if (MathUtils.IntersectRaySphere(ray, cloudTransform.TransformPoint(points.GetPosition(i)), points.GetPointScale() * 0.5f, ref t, ref zero) && (t > 0f)) { source.Add(i, t); } } if (source.Count <= 0) { return(-1); } if (< > f__am$cache5 == null) {
public static bool SelectPoints(IEditablePoint points, Transform cloudTransform, ref List <int> selection, bool firstSelect) { int controlID = GUIUtility.GetControlID(FocusType.Passive); bool result; if (Event.current.alt && Event.current.type != EventType.Repaint) { result = false; } else { bool flag = false; Event current = Event.current; switch (current.GetTypeForControl(controlID)) { case EventType.MouseDown: if ((HandleUtility.nearestControl == controlID || firstSelect) && current.button == 0) { if (!current.shift && !EditorGUI.actionKey) { selection.Clear(); flag = true; } PointEditor.s_SelectionStart = new List <int>(selection); GUIUtility.hotControl = controlID; PointEditor.s_StartMouseDragPosition = current.mousePosition; PointEditor.s_StartDragSelection = new List <int>(selection); current.Use(); } break; case EventType.MouseUp: if (GUIUtility.hotControl == controlID && current.button == 0) { if (!PointEditor.s_DidDrag) { int num = PointEditor.FindNearest(PointEditor.s_StartMouseDragPosition, cloudTransform, points); if (num != -1) { if (!current.shift && !EditorGUI.actionKey) { selection.Add(num); } else { int num2 = selection.IndexOf(num); if (num2 != -1) { selection.RemoveAt(num2); } else { selection.Add(num); } } } GUI.changed = true; flag = true; } PointEditor.s_StartDragSelection = null; PointEditor.s_StartMouseDragPosition = Vector2.zero; PointEditor.s_DidDrag = false; GUIUtility.hotControl = 0; current.Use(); } break; case EventType.MouseDrag: if (GUIUtility.hotControl == controlID && current.button == 0) { PointEditor.s_DidDrag = true; selection.Clear(); selection.AddRange(PointEditor.s_StartDragSelection); Rect rect = PointEditor.FromToRect(PointEditor.s_StartMouseDragPosition, current.mousePosition); Matrix4x4 matrix = Handles.matrix; Handles.matrix = cloudTransform.localToWorldMatrix; for (int i = 0; i < points.Count; i++) { Vector2 point = HandleUtility.WorldToGUIPoint(points.GetPosition(i)); if (rect.Contains(point)) { if (EditorGUI.actionKey) { if (PointEditor.s_SelectionStart.Contains(i)) { selection.Remove(i); } } else if (!PointEditor.s_SelectionStart.Contains(i)) { selection.Add(i); } } } Handles.matrix = matrix; GUI.changed = true; current.Use(); } break; case EventType.Repaint: if (GUIUtility.hotControl == controlID && current.mousePosition != PointEditor.s_StartMouseDragPosition) { GUIStyle gUIStyle = "SelectionRect"; Handles.BeginGUI(); gUIStyle.Draw(PointEditor.FromToRect(PointEditor.s_StartMouseDragPosition, current.mousePosition), false, false, false, false); Handles.EndGUI(); } break; case EventType.Layout: HandleUtility.AddDefaultControl(controlID); break; } if (flag) { selection = selection.Distinct <int>().ToList <int>(); } result = flag; } return(result); }
// This function implements selection of points. Returns true is selection changes public static bool SelectPoints(IEditablePoint points, Transform cloudTransform, ref List <int> selection, bool firstSelect) { int id = GUIUtility.GetControlID(FocusType.Passive); if (Event.current.alt && Event.current.type != EventType.Repaint) { return(false); } bool selectionChanged = false; Event evt = Event.current; switch (evt.GetTypeForControl(id)) { case EventType.Layout: // Tell the handles system that we're the default tool (the one that should get focus when user clicks on nothing else.) HandleUtility.AddDefaultControl(id); break; case EventType.MouseDown: // If we got a left-mouse down (HandleUtility.nearestControl== id is only true when the user clicked outside any handles), // we should begin selecting. if ((HandleUtility.nearestControl == id || firstSelect) && evt.button == 0) { // If neither shift nor control is held down, we'll clear the selection as the fist thing. if (!evt.shift && !EditorGUI.actionKey) { selection.Clear(); selectionChanged = true; } s_SelectionStart = new List <int>(selection); // Grab focus so that we can do a rect selection. GUIUtility.hotControl = id; // And remember where the drag was from. s_StartMouseDragPosition = evt.mousePosition; // Also remember the selection at the start so additive rect selection will work correctly s_StartDragSelection = new List <int>(selection); // Use the mouse down event so no other controls get them evt.Use(); } break; case EventType.MouseDrag: // The user dragged the mouse (and we have the focus from MouseDown). We have a rect selection here if (GUIUtility.hotControl == id && evt.button == 0) { s_DidDrag = true; // Start by resetting the selection to what it was when the drag began. selection.Clear(); selection.AddRange(s_StartDragSelection); // now, we'll go over every point and see if it's inside the Rect defined by the mouse position and // the start drag position Rect r = FromToRect(s_StartMouseDragPosition, evt.mousePosition); using (new Handles.DrawingScope()) { if (cloudTransform != null) { Handles.matrix = cloudTransform.localToWorldMatrix; } // Go over all the points and add them if they are inside the rect for (int i = 0; i < points.Count; i++) { var point = HandleUtility.WorldToGUIPoint(points.GetPosition(i)); if (r.Contains(point)) { if (EditorGUI.actionKey) { if (s_SelectionStart.Contains(i)) { selection.Remove(i); } } else { if (!s_SelectionStart.Contains(i)) { selection.Add(i); } } } } } // We'll assume the selection has changed and set GUI.changed to true. // Worst case, somebody will validate a bit too much, but oh well. GUI.changed = true; evt.Use(); } break; case EventType.MouseUp: // If we got the mousedown event, the mouseup is ours as well - this is where we clean up. if (GUIUtility.hotControl == id && evt.button == 0) { //Dragging vs clicking if (!s_DidDrag) { // Find out if it was on top of a point. int selectedPoint = FindNearest(s_StartMouseDragPosition, cloudTransform, points); // We found a point. We either need to make it selected or add it to an existing selection. if (selectedPoint != -1) { // If neither shift nor action is held down, simply set selection to the picked point. if (!evt.shift && !EditorGUI.actionKey) { selection.Add(selectedPoint); } else { // Shift was held down. This means we need to add/remove the point int alreadyInSelection = selection.IndexOf(selectedPoint); if (alreadyInSelection != -1) { selection.RemoveAt(alreadyInSelection); } else { selection.Add(selectedPoint); } } } // Selection has changed. set GUI.changed to true so caller can react (e.g. repaint inspector). GUI.changed = true; selectionChanged = true; } // Clean up various stuff. s_StartDragSelection = null; s_StartMouseDragPosition = Vector2.zero; s_DidDrag = false; // Release the mouse focus GUIUtility.hotControl = 0; // use the event evt.Use(); } break; case EventType.Repaint: // If we have focus and the mouse has been moved, we'll the draw selection rect. if (GUIUtility.hotControl == id && evt.mousePosition != s_StartMouseDragPosition) { GUIStyle gs = "SelectionRect"; Handles.BeginGUI(); gs.Draw(FromToRect(s_StartMouseDragPosition, evt.mousePosition), false, false, false, false); Handles.EndGUI(); } break; } if (selectionChanged) { selection = selection.Distinct().ToList(); } return(selectionChanged); }
public static bool SelectPoints(IEditablePoint points, Transform cloudTransform, ref List<int> selection, bool firstSelect) { int controlId = GUIUtility.GetControlID(FocusType.Passive); if (Event.current.alt && Event.current.type != EventType.Repaint) return false; bool flag = false; Event current = Event.current; switch (current.GetTypeForControl(controlId)) { case EventType.MouseDown: if ((HandleUtility.nearestControl == controlId || firstSelect) && current.button == 0) { if (!current.shift && !EditorGUI.actionKey) { selection.Clear(); flag = true; } GUIUtility.hotControl = controlId; PointEditor.s_StartMouseDragPosition = current.mousePosition; PointEditor.s_StartDragSelection = new List<int>((IEnumerable<int>) selection); current.Use(); break; } break; case EventType.MouseUp: if (GUIUtility.hotControl == controlId && current.button == 0) { if (!PointEditor.s_DidDrag) { int nearest = PointEditor.FindNearest(PointEditor.s_StartMouseDragPosition, cloudTransform, points); if (nearest != -1) { if (!current.shift && !EditorGUI.actionKey) { selection.Add(nearest); } else { int index = selection.IndexOf(nearest); if (index != -1) selection.RemoveAt(index); else selection.Add(nearest); } } GUI.changed = true; flag = true; } PointEditor.s_StartDragSelection = (List<int>) null; PointEditor.s_StartMouseDragPosition = Vector2.zero; PointEditor.s_DidDrag = false; GUIUtility.hotControl = 0; current.Use(); break; } break; case EventType.MouseDrag: if (GUIUtility.hotControl == controlId && current.button == 0) { PointEditor.s_DidDrag = true; selection.Clear(); selection.AddRange((IEnumerable<int>) PointEditor.s_StartDragSelection); Rect rect = PointEditor.FromToRect(PointEditor.s_StartMouseDragPosition, current.mousePosition); Matrix4x4 matrix = Handles.matrix; Handles.matrix = cloudTransform.localToWorldMatrix; for (int idx = 0; idx < points.Count; ++idx) { Vector2 guiPoint = HandleUtility.WorldToGUIPoint(points.GetPosition(idx)); if (rect.Contains(guiPoint)) selection.Add(idx); } Handles.matrix = matrix; GUI.changed = true; current.Use(); break; } break; case EventType.Repaint: if (GUIUtility.hotControl == controlId && current.mousePosition != PointEditor.s_StartMouseDragPosition) { GUIStyle guiStyle = (GUIStyle) "SelectionRect"; Handles.BeginGUI(); guiStyle.Draw(PointEditor.FromToRect(PointEditor.s_StartMouseDragPosition, current.mousePosition), false, false, false, false); Handles.EndGUI(); break; } break; case EventType.Layout: HandleUtility.AddDefaultControl(controlId); break; } selection = selection.Distinct<int>().ToList<int>(); return flag; }
public static int FindNearest(Vector2 point, Transform cloudTransform, IEditablePoint points) { Ray worldRay = HandleUtility.GUIPointToWorldRay(point); Dictionary<int, float> source = new Dictionary<int, float>(); for (int index = 0; index < points.Count; ++index) { float t = 0.0f; Vector3 zero = Vector3.zero; if (MathUtils.IntersectRaySphere(worldRay, cloudTransform.TransformPoint(points.GetPosition(index)), points.GetPointScale() * 0.5f, ref t, ref zero) && (double) t > 0.0) source.Add(index, t); } if (source.Count <= 0) return -1; return source.OrderBy<KeyValuePair<int, float>, float>((Func<KeyValuePair<int, float>, float>) (x => x.Value)).First<KeyValuePair<int, float>>().Key; }
public static bool MovePoints(IEditablePoint points, Transform cloudTransform, List <int> selection) { if (selection.Count == 0) { return(false); } if (Event.current.type == EventType.MouseUp) { PointEditor.s_EditingScale = Vector3.one; PointEditor.s_EditingRotation = Quaternion.identity; } if (Camera.current) { Vector3 vector = Vector3.zero; vector = ((Tools.pivotMode != PivotMode.Pivot) ? (selection.Aggregate(vector, (Vector3 current, int index) => current + points.GetPosition(index)) / (float)selection.Count) : points.GetPosition(selection[0])); vector = cloudTransform.TransformPoint(vector); switch (Tools.current) { case Tool.Move: { Vector3 position = Handles.PositionHandle(vector, (Tools.pivotRotation != PivotRotation.Local) ? Quaternion.identity : cloudTransform.rotation); if (GUI.changed) { Vector3 b = cloudTransform.InverseTransformPoint(position) - cloudTransform.InverseTransformPoint(vector); foreach (int current4 in selection) { points.SetPosition(current4, points.GetPosition(current4) + b); } return(true); } break; } case Tool.Rotate: { Quaternion rotation = Handles.RotationHandle(PointEditor.s_EditingRotation, vector); if (GUI.changed) { Vector3 b2 = cloudTransform.InverseTransformPoint(vector); foreach (int current2 in selection) { Vector3 vector2 = points.GetPosition(current2) - b2; vector2 = Quaternion.Inverse(PointEditor.s_EditingRotation) * vector2; vector2 = rotation * vector2; vector2 += b2; points.SetPosition(current2, vector2); } PointEditor.s_EditingRotation = rotation; return(true); } break; } case Tool.Scale: { Vector3 vector3 = Handles.ScaleHandle(PointEditor.s_EditingScale, vector, Quaternion.identity, HandleUtility.GetHandleSize(vector)); if (GUI.changed) { Vector3 b3 = cloudTransform.InverseTransformPoint(vector); foreach (int current3 in selection) { Vector3 vector4 = points.GetPosition(current3) - b3; vector4.x /= PointEditor.s_EditingScale.x; vector4.y /= PointEditor.s_EditingScale.y; vector4.z /= PointEditor.s_EditingScale.z; vector4.x *= vector3.x; vector4.y *= vector3.y; vector4.z *= vector3.z; vector4 += b3; points.SetPosition(current3, vector4); } PointEditor.s_EditingScale = vector3; return(true); } break; } } } return(false); }
public static int FindNearest(Vector2 point, Transform cloudTransform, IEditablePoint points) { Ray ray = HandleUtility.GUIPointToWorldRay(point); Dictionary<int, float> dictionary = new Dictionary<int, float>(); for (int i = 0; i < points.Count; i++) { float num = 0f; Vector3 zero = Vector3.zero; if (MathUtils.IntersectRaySphere(ray, cloudTransform.TransformPoint(points.GetPosition(i)), points.GetPointScale() * 0.5f, ref num, ref zero) && num > 0f) { dictionary.Add(i, num); } } if (dictionary.Count <= 0) { return -1; } IOrderedEnumerable<KeyValuePair<int, float>> source = from x in dictionary orderby x.Value select x; return source.First<KeyValuePair<int, float>>().Key; }
public static bool MovePoints(IEditablePoint points, Transform cloudTransform, List<int> selection) { if (selection.Count == 0) { return false; } if (Event.current.type == EventType.MouseUp) { PointEditor.s_EditingScale = Vector3.one; PointEditor.s_EditingRotation = Quaternion.identity; } if (Camera.current) { Vector3 vector = Vector3.zero; vector = ((Tools.pivotMode != PivotMode.Pivot) ? (selection.Aggregate(vector, (Vector3 current, int index) => current + points.GetPosition(index)) / (float)selection.Count) : points.GetPosition(selection[0])); vector = cloudTransform.TransformPoint(vector); switch (Tools.current) { case Tool.Move: { Vector3 position = Handles.PositionHandle(vector, (Tools.pivotRotation != PivotRotation.Local) ? Quaternion.identity : cloudTransform.rotation); if (GUI.changed) { Vector3 b = cloudTransform.InverseTransformPoint(position) - cloudTransform.InverseTransformPoint(vector); foreach (int current4 in selection) { points.SetPosition(current4, points.GetPosition(current4) + b); } return true; } break; } case Tool.Rotate: { Quaternion rotation = Handles.RotationHandle(PointEditor.s_EditingRotation, vector); if (GUI.changed) { Vector3 b2 = cloudTransform.InverseTransformPoint(vector); foreach (int current2 in selection) { Vector3 vector2 = points.GetPosition(current2) - b2; vector2 = Quaternion.Inverse(PointEditor.s_EditingRotation) * vector2; vector2 = rotation * vector2; vector2 += b2; points.SetPosition(current2, vector2); } PointEditor.s_EditingRotation = rotation; return true; } break; } case Tool.Scale: { Vector3 vector3 = Handles.ScaleHandle(PointEditor.s_EditingScale, vector, Quaternion.identity, HandleUtility.GetHandleSize(vector)); if (GUI.changed) { Vector3 b3 = cloudTransform.InverseTransformPoint(vector); foreach (int current3 in selection) { Vector3 vector4 = points.GetPosition(current3) - b3; vector4.x /= PointEditor.s_EditingScale.x; vector4.y /= PointEditor.s_EditingScale.y; vector4.z /= PointEditor.s_EditingScale.z; vector4.x *= vector3.x; vector4.y *= vector3.y; vector4.z *= vector3.z; vector4 += b3; points.SetPosition(current3, vector4); } PointEditor.s_EditingScale = vector3; return true; } break; } } } return false; }
public static bool SelectPoints(IEditablePoint points, Transform cloudTransform, ref List <int> selection, bool firstSelect) { int controlId = GUIUtility.GetControlID(FocusType.Passive); if (Event.current.alt && Event.current.type != EventType.Repaint) { return(false); } bool flag = false; Event current = Event.current; switch (current.GetTypeForControl(controlId)) { case EventType.MouseDown: if ((HandleUtility.nearestControl == controlId || firstSelect) && current.button == 0) { if (!current.shift && !EditorGUI.actionKey) { selection.Clear(); flag = true; } GUIUtility.hotControl = controlId; PointEditor.s_StartMouseDragPosition = current.mousePosition; PointEditor.s_StartDragSelection = new List <int>((IEnumerable <int>)selection); current.Use(); break; } break; case EventType.MouseUp: if (GUIUtility.hotControl == controlId && current.button == 0) { if (!PointEditor.s_DidDrag) { int nearest = PointEditor.FindNearest(PointEditor.s_StartMouseDragPosition, cloudTransform, points); if (nearest != -1) { if (!current.shift && !EditorGUI.actionKey) { selection.Add(nearest); } else { int index = selection.IndexOf(nearest); if (index != -1) { selection.RemoveAt(index); } else { selection.Add(nearest); } } } GUI.changed = true; flag = true; } PointEditor.s_StartDragSelection = (List <int>)null; PointEditor.s_StartMouseDragPosition = Vector2.zero; PointEditor.s_DidDrag = false; GUIUtility.hotControl = 0; current.Use(); break; } break; case EventType.MouseDrag: if (GUIUtility.hotControl == controlId && current.button == 0) { PointEditor.s_DidDrag = true; selection.Clear(); selection.AddRange((IEnumerable <int>)PointEditor.s_StartDragSelection); Rect rect = PointEditor.FromToRect(PointEditor.s_StartMouseDragPosition, current.mousePosition); Matrix4x4 matrix = Handles.matrix; Handles.matrix = cloudTransform.localToWorldMatrix; for (int idx = 0; idx < points.Count; ++idx) { Vector2 guiPoint = HandleUtility.WorldToGUIPoint(points.GetPosition(idx)); if (rect.Contains(guiPoint)) { selection.Add(idx); } } Handles.matrix = matrix; GUI.changed = true; current.Use(); break; } break; case EventType.Repaint: if (GUIUtility.hotControl == controlId && current.mousePosition != PointEditor.s_StartMouseDragPosition) { GUIStyle guiStyle = (GUIStyle)"SelectionRect"; Handles.BeginGUI(); guiStyle.Draw(PointEditor.FromToRect(PointEditor.s_StartMouseDragPosition, current.mousePosition), false, false, false, false); Handles.EndGUI(); break; } break; case EventType.Layout: HandleUtility.AddDefaultControl(controlId); break; } selection = selection.Distinct <int>().ToList <int>(); return(flag); }
public static int FindNearest(Vector2 point, Transform cloudTransform, IEditablePoint points) { Ray worldRay = HandleUtility.GUIPointToWorldRay(point); Dictionary <int, float> source = new Dictionary <int, float>(); for (int index = 0; index < points.Count; ++index) { float t = 0.0f; Vector3 zero = Vector3.zero; if (MathUtils.IntersectRaySphere(worldRay, cloudTransform.TransformPoint(points.GetPosition(index)), points.GetPointScale() * 0.5f, ref t, ref zero) && (double)t > 0.0) { source.Add(index, t); } } if (source.Count <= 0) { return(-1); } return(source.OrderBy <KeyValuePair <int, float>, float>((Func <KeyValuePair <int, float>, float>)(x => x.Value)).First <KeyValuePair <int, float> >().Key); }
public static bool SelectPoints(IEditablePoint points, Transform cloudTransform, ref List <int> selection, bool firstSelect) { int controlID = GUIUtility.GetControlID(FocusType.Passive); if (Event.current.alt && (Event.current.type != EventType.Repaint)) { return(false); } bool flag2 = false; Event current = Event.current; switch (current.GetTypeForControl(controlID)) { case EventType.MouseDown: if (((HandleUtility.nearestControl == controlID) || firstSelect) && (current.button == 0)) { if (!current.shift && !EditorGUI.actionKey) { selection.Clear(); flag2 = true; } s_SelectionStart = new List <int>(selection); GUIUtility.hotControl = controlID; s_StartMouseDragPosition = current.mousePosition; s_StartDragSelection = new List <int>(selection); current.Use(); } goto Label_02F5; case EventType.MouseUp: { if ((GUIUtility.hotControl != controlID) || (current.button != 0)) { goto Label_02F5; } if (s_DidDrag) { goto Label_0275; } int item = FindNearest(s_StartMouseDragPosition, cloudTransform, points); if (item != -1) { if (current.shift || EditorGUI.actionKey) { int index = selection.IndexOf(item); if (index != -1) { selection.RemoveAt(index); } else { selection.Add(item); } break; } selection.Add(item); } break; } case EventType.MouseDrag: if ((GUIUtility.hotControl == controlID) && (current.button == 0)) { s_DidDrag = true; selection.Clear(); selection.AddRange(s_StartDragSelection); Rect rect = FromToRect(s_StartMouseDragPosition, current.mousePosition); Matrix4x4 matrix = Handles.matrix; Handles.matrix = cloudTransform.localToWorldMatrix; for (int i = 0; i < points.Count; i++) { Vector2 point = HandleUtility.WorldToGUIPoint(points.GetPosition(i)); if (rect.Contains(point)) { if (EditorGUI.actionKey) { if (s_SelectionStart.Contains(i)) { selection.Remove(i); } } else if (!s_SelectionStart.Contains(i)) { selection.Add(i); } } } Handles.matrix = matrix; GUI.changed = true; current.Use(); } goto Label_02F5; case EventType.Repaint: if ((GUIUtility.hotControl == controlID) && (current.mousePosition != s_StartMouseDragPosition)) { GUIStyle style = "SelectionRect"; Handles.BeginGUI(); style.Draw(FromToRect(s_StartMouseDragPosition, current.mousePosition), false, false, false, false); Handles.EndGUI(); } goto Label_02F5; case EventType.Layout: HandleUtility.AddDefaultControl(controlID); goto Label_02F5; default: goto Label_02F5; } GUI.changed = true; flag2 = true; Label_0275: s_StartDragSelection = null; s_StartMouseDragPosition = Vector2.zero; s_DidDrag = false; GUIUtility.hotControl = 0; current.Use(); Label_02F5: if (flag2) { selection = selection.Distinct <int>().ToList <int>(); } return(flag2); }