Table of Contents
Extensions for Texture2Ds
public static class Texture2DExt
Inheritance System.Object Texture2DExt
Applies a HSV adjustment, shifting its Hue/Saturation/Value(light)
public static RenderTexture AdjustHSV(this Texture texture, float hueAdjust, float saturationAdjust, float valueAdjust, System.Nullable<Color> targetColor=null, float threshold=0.05f);
texture
UnityEngine.Texture
this
hueAdjust
System.Single
Amount between -180 and 180 to add to Hue
saturationAdjust
System.Single
Amount between -1 and 1 to add to the saturation
valueAdjust
System.Single
Amount between -1 and 1 to add to the value (light)
targetColor
System.Nullable<UnityEngine.Color>
If specified, only affect this color within the image
threshold
System.Single
If specified, only match the color within this threshold, 0 is exact, 1 will match anything
Applies a custom Mod Helper shader, creating a new Texture with its effects baked in
public static RenderTexture ApplyCustomShader(this Texture texture, BTD_Mod_Helper.Api.Enums.CustomShader customShader, System.Action<Material> modifyMaterial=null);
texture
UnityEngine.Texture
this
customShader
CustomShader
Mod Helper custom shader
modifyMaterial
System.Action<UnityEngine.Material>
changes to make to the material
Create Texture2D from a unity Color. Texture will only be this color
public static Texture2D CreateFromColor(this Texture2D texture2D, Color color);
texture2D
UnityEngine.Texture2D
color
UnityEngine.Color
Color to make new texture
Create a Sprite from this Texture2D
public static Sprite CreateSpriteFromTexture(this Texture2D texture2D, float pixelsPerUnit, Vector2 pivot);
texture2D
UnityEngine.Texture2D
pixelsPerUnit
System.Single
Number of pixels you want in each unit. More pixels means bigger sprite in game
pivot
UnityEngine.Vector2
Create a Sprite from this Texture2D
public static Sprite CreateSpriteFromTexture(this Texture2D texture2D, float pixelsPerUnit);
texture2D
UnityEngine.Texture2D
pixelsPerUnit
System.Single
Number of pixels you want in each unit. More pixels means bigger sprite in game
Create Texture2D from a file on local PC
public static Texture2D LoadFromFile(this Texture2D texture, string filePath);
texture
UnityEngine.Texture2D
filePath
System.String
path of file on PC
Replaces all the usage of a target color (within a certain threshold) with a replacement color
public static RenderTexture ReplaceColor(this Texture texture, Color targetColor, Color replacementColor, float threshold=0.05f);
texture
UnityEngine.Texture
this
targetColor
UnityEngine.Color
The color to find
replacementColor
UnityEngine.Color
The new color
threshold
System.Single
The threshold for matching the target color, 0 is exact, 1 will match anything
Save Texture2D as a png to file.
public static void SaveToPNG(this Texture2D texture, string filePath);
texture
UnityEngine.Texture2D
filePath
System.String
File path to save texture to
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);
texture
UnityEngine.Texture
filePath
System.String