Table of Contents
Helper class for getting resized versions of Sprites
public static class SpriteResizer
Inheritance System.Object SpriteResizer
Create a new Sprite that appears scaled by (scaleX, scaleY) inside a fixed UI rect
by adding transparent padding around the original sprite.
Works even if src.texture is not readable.
public static Sprite PadSpriteToScale(this Sprite src, float uniformScale);
uniformScale
System.Single
Create a new Sprite that appears scaled by (scaleX, scaleY) inside a fixed UI rect
by adding transparent padding around the original sprite.
Works even if src.texture is not readable.
public static Sprite PadSpriteToScale(this Sprite src, float scaleX, float scaleY);
scaleX
System.Single
scaleY
System.Single
Returns a new Sprite with a square texture by padding the shorter axis
with transparent pixels so that width and height are equal.
public static Sprite PadSpriteToSquare(this Sprite src);
The source sprite to pad.
UnityEngine.Sprite
A new square Sprite instance if padding was needed, or the original sprite if already square.
Returns a modified Sprite GUID that will create a reference to a resized version of this Vanilla Sprite.
public static string Scaled(string spriteGuid, float scale, bool square=true);
spriteGuid
System.String
Vanilla Sprite guid
scale
System.Single
square
System.Boolean
also make the final image a square shape
System.String
new sprite guid
Returns a modified Sprite GUID that will create a reference to a resized version of this Vanilla Sprite.
public static string Scaled(string spriteGuid, float scaleX, float scaleY, bool square=true);
spriteGuid
System.String
Vanilla Sprite guid
scaleX
System.Single
scale
scaleY
System.Single
scale
square
System.Boolean
also make the final image a square shape
System.String
new sprite guid