Skip to Main Content

BTD_Mod_Helper​.Api​.Helpers​.SpriteResizer


BloonsTD6 Mod Helper

BTD_Mod_Helper.Api.Helpers

SpriteResizer Class

Helper class for getting resized versions of Sprites

public static class SpriteResizer

Inheritance System.Object  SpriteResizer

Methods

SpriteResizer.PadSpriteToScale(this Sprite, float) Method

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);

Parameters

src UnityEngine.Sprite

uniformScale System.Single

Returns

UnityEngine.Sprite

SpriteResizer.PadSpriteToScale(this Sprite, float, float) Method

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);

Parameters

src UnityEngine.Sprite

scaleX System.Single

scaleY System.Single

Returns

UnityEngine.Sprite

SpriteResizer.PadSpriteToSquare(this Sprite) Method

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);

Parameters

src UnityEngine.Sprite

The source sprite to pad.

Returns

UnityEngine.Sprite
A new square Sprite instance if padding was needed, or the original sprite if already square.

SpriteResizer.Scaled(string, float, bool) Method

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);

Parameters

spriteGuid System.String

Vanilla Sprite guid

scale System.Single

square System.Boolean

also make the final image a square shape

Returns

System.String
new sprite guid

SpriteResizer.Scaled(string, float, float, bool) Method

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);

Parameters

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

Returns

System.String
new sprite guid

To learn how to download BTD Mod Helper and install mods, click here