forked from knah/VRCMods
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SpriteJson.cs
41 lines (32 loc) · 946 Bytes
/
SpriteJson.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
using UnityEngine;
namespace Styletor.Jsons
{
public class SpriteJson
{
// These correspond to Sprite.border
public float BorderLeft;
public float BorderBottom;
public float BorderRight;
public float BorderTop;
// These correspond to Sprite.pivot, in 0-1 range
public float PivotX = 0.5f;
public float PivotY = 0.5f;
// Sprite.pixelsPerUnit
public float PixelsPerUnit = 100;
public SpriteJson()
{
}
public SpriteJson(Sprite sprite)
{
var pivotRel = sprite.pivot / sprite.rect.size;
var border = sprite.border;
PixelsPerUnit = sprite.pixelsPerUnit;
PivotX = pivotRel.x;
PivotY = pivotRel.y;
BorderLeft = border.x;
BorderBottom = border.y;
BorderRight = border.z;
BorderTop = border.w;
}
}
}