Example #1
0
        private void DoRectSelectionGUI()
        {
            ISelection selection = ShapeEditorCache.GetSelection();

            if (m_RectSelectionID == -1)
            {
                m_RectSelectionID = GUIUtility.GetControlID("RectSelection".GetHashCode(), FocusType.Passive);
            }

            if (Event.current.GetTypeForControl(m_RectSelectionID) == EventType.MouseDown && Event.current.button == 0)
            {
                if (!Event.current.shift && !EditorGUI.actionKey)
                {
                    ShapeEditorCache.RecordUndo("Edit Selection");
                    ShapeEditorCache.ClearSelection();
                    GUI.changed = true;
                }
            }

            if (Event.current.GetTypeForControl(m_RectSelectionID) == EventType.MouseUp && Event.current.button == 0)
            {
                ShapeEditorCache.RecordUndo("Edit Selection");

                selection.EndSelection(true);
                m_ShapeEditor.HandleSinglePointSelection();

                GUI.changed = true;
            }

            EditorGUI.BeginChangeCheck();

            Rect selectionRect = m_RectSelectionTool.Do(m_RectSelectionID, (m_CurrentEditor.target as Component).transform.position);

            if (EditorGUI.EndChangeCheck())
            {
                selection.BeginSelection();

                for (int i = 0; i < m_Spline.GetPointCount(); ++i)
                {
                    if (selectionRect.Contains(HandleUtility.WorldToGUIPoint(LocalToWorld(m_Spline.GetPosition(i))), true))
                    {
                        selection.Select(i, true);
                    }
                }
            }
        }