Exemple #1
0
        public void OnEnable()
        {
            m_SpriteShape = target as SpriteShape;

            m_FillTextureProp      = this.serializedObject.FindProperty("m_FillTexture");
            m_WorldSpaceUVProp     = this.serializedObject.FindProperty("m_WorldSpaceUV");
            m_UseSpriteBordersProp = serializedObject.FindProperty("m_UseSpriteBorders");
            m_AngleRangesProp      = this.serializedObject.FindProperty("m_Angles");
            m_CornerSpritesProp    = this.serializedObject.FindProperty("m_CornerSprites");
            m_BevelCutoffProp      = this.serializedObject.FindProperty("m_BevelCutoff");
            m_BevelSizeProp        = this.serializedObject.FindProperty("m_BevelSize");
            m_FillOffsetProp       = this.serializedObject.FindProperty("m_FillOffset");
            m_FillPixelPerUnitProp = this.serializedObject.FindProperty("m_FillPixelPerUnit");

            m_FadeControlPoint = new AnimBool(false);
            m_FadeControlPoint.valueChanged.AddListener(Repaint);

            m_FadeAngleRange = new AnimBool(false);
            m_FadeAngleRange.valueChanged.AddListener(Repaint);

            selectedIndex = SpriteShapeEditorUtility.GetRangeIndexFromAngle(angleRanges, m_PreviewAngle);

            SetupAngleRangeController();

            Undo.undoRedoPerformed += UndoRedoPerformed;
        }
Exemple #2
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);
        }
 public static void CreateNewSpriteShape()
 {
     UnityEngine.U2D.SpriteShape newSpriteShape = SpriteShapeEditorUtility.CreateSpriteShapeAsset();
     newSpriteShape.angleRanges.Add(CreateAngleRange(-45.0f, 45.0f, 4));
     newSpriteShape.angleRanges.Add(CreateAngleRange(-135.0f, -45.0f, 3));
     newSpriteShape.angleRanges.Add(CreateAngleRange(135.0f, 225.0f, 2));
     newSpriteShape.angleRanges.Add(CreateAngleRange(45.0f, 135.0f, 1));
 }
Exemple #4
0
        private int GetAngleRangeLocal(int index)
        {
            var selection       = SplineEditorCache.GetSelection();
            var spriteShape     = SplineEditorCache.GetTarget().spriteShape;
            var nextIndex       = SplineUtility.NextIndex(selection.single, GetPointCount());
            var pos1            = GetLocalPosition(selection.single);
            var pos2            = GetLocalPosition(nextIndex);
            var angle           = SplineUtility.SlopeAngle(pos1, pos2) + 90;
            var angleRangeIndex = SpriteShapeEditorUtility.GetRangeIndexFromAngle(spriteShape, angle);

            return(angleRangeIndex);
        }
Exemple #5
0
        static GameObject CreateDragGO(SpriteShape spriteShape, Vector3 position)
        {
            SpriteShapeController spriteShapeController = SpriteShapeEditorUtility.CreateSpriteShapeController();
            GameObject            gameObject            = spriteShapeController.gameObject;

            gameObject.transform.position     = position;
            gameObject.hideFlags              = HideFlags.HideAndDontSave;
            spriteShapeController.spriteShape = spriteShape;

            SpriteShapeEditorUtility.SetShapeFromAsset(spriteShapeController);

            return(gameObject);
        }
Exemple #6
0
        public static void CreateNewSpriteShape()
        {
            SpriteShape newSpriteShape = SpriteShapeEditorUtility.CreateSpriteShapeAsset();

            newSpriteShape.angleRanges.Add(CreateAngleRange(-22.5f, 22.5f, 7));
            newSpriteShape.angleRanges.Add(CreateAngleRange(22.5f, 67.5f, 6));
            newSpriteShape.angleRanges.Add(CreateAngleRange(67.5f, 112.5f, 4));
            newSpriteShape.angleRanges.Add(CreateAngleRange(112.5f, 157.5f, 2));
            newSpriteShape.angleRanges.Add(CreateAngleRange(157.5f, 202.5f, 8));
            newSpriteShape.angleRanges.Add(CreateAngleRange(-157.5f, -112.5f, 1));
            newSpriteShape.angleRanges.Add(CreateAngleRange(-112.5f, -67.5f, 3));
            newSpriteShape.angleRanges.Add(CreateAngleRange(-67.5f, -22.5f, 5));
        }
Exemple #7
0
        public void OnEnable()
        {
            m_PreviewAngle = SessionState.GetFloat("SpriteShape/PreviewAngle/" + target.GetInstanceID(), m_PreviewAngle);

            m_SpriteShape = target as SpriteShape;

            m_FillTextureProp      = this.serializedObject.FindProperty("m_FillTexture");
            m_UseSpriteBordersProp = serializedObject.FindProperty("m_UseSpriteBorders");
            m_AngleRangesProp      = this.serializedObject.FindProperty("m_Angles");
            m_CornerSpritesProp    = this.serializedObject.FindProperty("m_CornerSprites");
            m_FillOffsetProp       = this.serializedObject.FindProperty("m_FillOffset");

            selectedIndex = SpriteShapeEditorUtility.GetRangeIndexFromAngle(angleRanges, m_PreviewAngle);

            SetupAngleRangeController();

            Undo.undoRedoPerformed += UndoRedoPerformed;
        }
        public static void SetShapeFromAsset(SpriteShapeController spriteShapeController)
        {
            SpriteShape spriteShape = spriteShapeController.spriteShape;

            if (!spriteShape)
            {
                SpriteShapeEditorUtility.SetToSquare(spriteShapeController);
                return;
            }

            if (spriteShape.angleRanges.Count == 1 && spriteShape.angleRanges[0].end - spriteShape.angleRanges[0].start == 360f)
            {
                SpriteShapeEditorUtility.SetToLine(spriteShapeController);
            }
            else if (spriteShape.angleRanges.Count < 8)
            {
                SpriteShapeEditorUtility.SetToSquare(spriteShapeController);
            }
            else
            {
                SpriteShapeEditorUtility.SetToOctogon(spriteShapeController);
            }
        }
        private void SetSelectedIndexFromPreviewAngle()
        {
            var index = SpriteShapeEditorUtility.GetRangeIndexFromAngle(cache.angleRanges, cache.previewAngle);

            SelectIndex(index);
        }
 internal static void CreateSpriteShapeEmpty()
 {
     SpriteShapeEditorUtility.SetShapeFromAsset(SpriteShapeEditorUtility.CreateSpriteShapeControllerFromSelection());
 }
 public static void CreateNewSpriteStrip()
 {
     UnityEngine.U2D.SpriteShape newSpriteShape = SpriteShapeEditorUtility.CreateSpriteShapeAsset();
     newSpriteShape.angleRanges.Add(CreateAngleRange(-180.0f, 180.0f, 0));
 }
 void InitCache()
 {
     selectedIndex = SpriteShapeEditorUtility.GetRangeIndexFromAngle(angleRanges, m_PreviewAngle);
     SetupAngleRangeController();
 }
Exemple #13
0
 public static void CreateNewEmptySpriteShape()
 {
     SpriteShapeEditorUtility.CreateSpriteShapeAsset();
 }