Example #1
0
        public void CycleSpriteIndex()
        {
            ISelection selection = ShapeEditorCache.GetSelection();

            if (selection.single == -1)
            {
                return;
            }

            int   nextIndex       = SplineUtility.NextIndex(selection.single, m_Spline.GetPointCount());
            float angle           = SpriteShapeHandleUtility.PosToAngle(m_Spline.GetPosition(selection.single), m_Spline.GetPosition(nextIndex), 0f);
            int   angleRangeIndex = SpriteShapeEditorUtility.GetRangeIndexFromAngle(m_SpriteShape, angle);

            if (angleRangeIndex == -1)
            {
                return;
            }

            AngleRange angleRange = m_SpriteShape.angleRanges[angleRangeIndex];

            int spriteIndex = (m_Spline.GetSpriteIndex(selection.single) + 1) % angleRange.sprites.Count;

            Undo.RecordObject(m_CurrentEditor.target, "Edit Sprite Index");

            m_Spline.SetSpriteIndex(selection.single, spriteIndex);

            EditorUtility.SetDirty(m_CurrentEditor.target);
        }
Example #2
0
 public float GetAngleFromPosition(Rect rect, float angleOffset)
 {
     return(Mathf.RoundToInt(SpriteShapeHandleUtility.PosToAngle(Event.current.mousePosition, rect.center, -angleOffset)));
 }