Extensions for Texture2Ds
public static class Texture2DExt
Inheritance System.Object Texture2DExt
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);
texture2D
UnityEngine.Texture2D
pixelsPerUnit
System.Single
Number of pixels you want in each unit. More pixels means bigger sprite in game
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 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
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