mirror of
https://github.com/RHeavenStudioPlus/HeavenStudioPlus.git
synced 2024-11-24 10:35:16 +00:00
fix spritesheet scaler incorrectly setting pivots
This commit is contained in:
parent
ba02f2a56f
commit
e57eda7af6
2 changed files with 7 additions and 3 deletions
|
@ -77,7 +77,8 @@ public class SpritesheetScaler : EditorWindow
|
||||||
for (int i = 0; i < ti1.spritesheet.Length; i++)
|
for (int i = 0; i < ti1.spritesheet.Length; i++)
|
||||||
{
|
{
|
||||||
SpriteMetaData d = ti1.spritesheet[i];
|
SpriteMetaData d = ti1.spritesheet[i];
|
||||||
Vector2 oldPivot = Rect.NormalizedToPoint(d.rect, d.pivot) * multiplier;
|
// pivot relative to the origin of the rect in pixels
|
||||||
|
Vector2 oldPivot = new Vector2(d.pivot.x * d.rect.width, d.pivot.y * d.rect.height);
|
||||||
d.rect = ScaleRect(d.rect, multiplier, inflateX, inflateY);
|
d.rect = ScaleRect(d.rect, multiplier, inflateX, inflateY);
|
||||||
|
|
||||||
d.border.x += d.border.x > 0 ? inflateX : 0;
|
d.border.x += d.border.x > 0 ? inflateX : 0;
|
||||||
|
@ -85,10 +86,12 @@ public class SpritesheetScaler : EditorWindow
|
||||||
d.border.z += d.border.z > 0 ? inflateX : 0;
|
d.border.z += d.border.z > 0 ? inflateX : 0;
|
||||||
d.border.w += d.border.w > 0 ? inflateY : 0;
|
d.border.w += d.border.w > 0 ? inflateY : 0;
|
||||||
|
|
||||||
if (inflateX > 0 || inflateY > 0)
|
if (d.alignment != (int)SpriteAlignment.Center && (inflateX > 0 || inflateY > 0))
|
||||||
{
|
{
|
||||||
d.alignment = (int)SpriteAlignment.Custom;
|
d.alignment = (int)SpriteAlignment.Custom;
|
||||||
d.pivot = Rect.PointToNormalized(d.rect, oldPivot);
|
oldPivot += new Vector2(inflateX, inflateY);
|
||||||
|
Vector2 newPivot = oldPivot * multiplier;
|
||||||
|
d.pivot = new Vector2(newPivot.x / d.rect.width, newPivot.y / d.rect.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
d.border *= multiplier;
|
d.border *= multiplier;
|
||||||
|
|
|
@ -23,5 +23,6 @@ MonoBehaviour:
|
||||||
- Assets/Scripts/Games/Minigame.cs
|
- Assets/Scripts/Games/Minigame.cs
|
||||||
- Assets/Scripts/Games/FanClub/FanClub.cs
|
- Assets/Scripts/Games/FanClub/FanClub.cs
|
||||||
- Assets/Scripts/GameManager.cs
|
- Assets/Scripts/GameManager.cs
|
||||||
|
- Assets/Editor/SpritesheetScaler.cs
|
||||||
PathsToSkipImportEvent: []
|
PathsToSkipImportEvent: []
|
||||||
PathsToIgnoreOverwriteSettingOnAttribute: []
|
PathsToIgnoreOverwriteSettingOnAttribute: []
|
||||||
|
|
Loading…
Reference in a new issue