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

            GUI.changed = true;
        }
        private void ValidateTangents(bool rightTangentChanged)
        {
            ISelection selection = ShapeEditorCache.GetSelection();

            TangentMode mode         = GetTangentMode(selection.single);
            Vector3     leftTangent  = GetLeftTangent(selection.single);
            Vector3     rightTangent = GetRightTangent(selection.single);

            if (mode == TangentMode.Continuous)
            {
                if (rightTangentChanged)
                {
                    leftTangent = -rightTangent;
                }
                else
                {
                    rightTangent = -leftTangent;
                }
            }

            SetLeftTangent(selection.single, leftTangent);
            SetRightTangent(selection.single, rightTangent);

            ShapeEditorCache.RecordUndo();
            ShapeEditorCache.instance.rightTangentChanged = rightTangentChanged;
            if (rightTangentChanged)
            {
                ShapeEditorCache.instance.rightTangent = rightTangent;
            }
            else
            {
                ShapeEditorCache.instance.leftTangent = leftTangent;
            }
        }
Example #3
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();
            }
        }