2022-01-12 10:06:03 +03:00
|
|
|
|
using UnityEngine;
|
|
|
|
|
using UnityEngine.U2D;
|
|
|
|
|
using UnityEditor.U2D.SpriteShape;
|
|
|
|
|
|
|
|
|
|
namespace UnityEditor.U2D
|
|
|
|
|
{
|
|
|
|
|
public class ContextMenu
|
|
|
|
|
{
|
|
|
|
|
private static AngleRange CreateAngleRange(float start, float end, int order)
|
|
|
|
|
{
|
|
|
|
|
AngleRange angleRange = new AngleRange();
|
|
|
|
|
|
|
|
|
|
angleRange.start = start;
|
|
|
|
|
angleRange.end = end;
|
|
|
|
|
angleRange.order = order;
|
|
|
|
|
|
|
|
|
|
return angleRange;
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-12 10:39:15 +03:00
|
|
|
|
//[MenuItem("Assets/Create/Sprite Shape Profile/Open Shape", false, 358)]
|
2022-01-12 10:06:03 +03:00
|
|
|
|
public static void CreateNewSpriteStrip()
|
|
|
|
|
{
|
|
|
|
|
UnityEngine.U2D.SpriteShape newSpriteShape = SpriteShapeEditorUtility.CreateSpriteShapeAsset();
|
|
|
|
|
newSpriteShape.angleRanges.Add(CreateAngleRange(-180.0f, 180.0f, 0));
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-12 10:39:15 +03:00
|
|
|
|
//[MenuItem("Assets/Create/Sprite Shape Profile/Closed Shape", false, 359)]
|
2022-01-12 10:06:03 +03:00
|
|
|
|
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));
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-12 10:39:15 +03:00
|
|
|
|
//[MenuItem("GameObject/2D Object/Sprite Shape")]
|
2022-01-12 10:06:03 +03:00
|
|
|
|
internal static void CreateSpriteShapeEmpty()
|
|
|
|
|
{
|
|
|
|
|
SpriteShapeEditorUtility.SetShapeFromAsset(SpriteShapeEditorUtility.CreateSpriteShapeControllerFromSelection());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|