private void ClearSelection()
        {
            ShapeEditorCache.RecordUndo("Edit Selection");
            ShapeEditorCache.ClearSelection();

            GUI.changed = true;
        }
Exemplo n.º 2
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);
                    }
                }
            }
        }
        private void SelectPoint(int index)
        {
            ISelection selection = ShapeEditorCache.GetSelection();

            bool additive    = currentEvent.shift;
            bool subtractive = EditorGUI.actionKey;

            ShapeEditorCache.RecordUndo("Edit Selection");

            if (!additive && !subtractive)
            {
                ShapeEditorCache.ClearSelection();
            }

            selection.Select(index, (!selection.IsSelected(index) || additive) && !subtractive);

            HandleSinglePointSelection();

            GUI.changed = true;
        }
        private void ValidateSelection()
        {
            int pointCount = m_SpriteShapeController.spline.GetPointCount();

            bool selectionValid = true;

            ISelection selection = ShapeEditorCache.GetSelection();

            foreach (int index in selection)
            {
                if (index >= pointCount)
                {
                    selectionValid = false;
                    break;
                }
            }

            if (!selectionValid)
            {
                ShapeEditorCache.RecordUndo();
                ShapeEditorCache.ClearSelection();
            }
        }