Skip to Main Content

BTD_Mod_Helper.Extensions.Texture2DExt


BloonsTD6 Mod Helper

BTD_Mod_Helper.Extensions

Texture2DExt Class

Extensions for Texture2Ds

public static class Texture2DExt

Inheritance System.Object  Texture2DExt

Methods

Texture2DExt.CreateFromColor(this Texture2D, Color) Method

Create Texture2D from a unity Color. Texture will only be this color

public static Texture2D CreateFromColor(this Texture2D texture2D, Color color);

Parameters

texture2D UnityEngine.Texture2D

color UnityEngine.Color

Color to make new texture

Returns

UnityEngine.Texture2D

Texture2DExt.CreateSpriteFromTexture(this Texture2D, float) Method

Create a Sprite from this Texture2D

public static Sprite CreateSpriteFromTexture(this Texture2D texture2D, float pixelsPerUnit);

Parameters

texture2D UnityEngine.Texture2D

pixelsPerUnit System.Single

Number of pixels you want in each unit. More pixels means bigger sprite in game

Returns

UnityEngine.Sprite

Texture2DExt.CreateSpriteFromTexture(this Texture2D, float, Vector2) Method

Create a Sprite from this Texture2D

public static Sprite CreateSpriteFromTexture(this Texture2D texture2D, float pixelsPerUnit, Vector2 pivot);

Parameters

texture2D UnityEngine.Texture2D

pixelsPerUnit System.Single

Number of pixels you want in each unit. More pixels means bigger sprite in game

pivot UnityEngine.Vector2

Returns

UnityEngine.Sprite

Texture2DExt.LoadFromFile(this Texture2D, string) Method

Create Texture2D from a file on local PC

public static Texture2D LoadFromFile(this Texture2D texture, string filePath);

Parameters

texture UnityEngine.Texture2D

filePath System.String

path of file on PC

Returns

UnityEngine.Texture2D

Texture2DExt.SaveToPNG(this Texture2D, string) Method

Save Texture2D as a png to file.

public static void SaveToPNG(this Texture2D texture, string filePath);

Parameters

texture UnityEngine.Texture2D

filePath System.String

File path to save texture to

Texture2DExt.TrySaveToPNG(this Texture, string) Method

Attempts to save a Texture to a png at the given filePath, even if it isn't marked as readable

public static void TrySaveToPNG(this Texture texture, string filePath);

Parameters

texture UnityEngine.Texture

filePath System.String

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