Version 3.3.1.2

TextureUtilities class

Namespace: Sirenix.Utilities.Editor
Assembly: Sirenix.Utilities.Editor
public static class TextureUtilities
Collection of texture functions.
Inheritance
  • System.Object
  • TextureUtilities

Methods

ConvertSpriteToTexture(Sprite)
Converts a Sprite to a Texture2D.
public static Texture2D ConvertSpriteToTexture(Sprite sprite)
Parameters
UnityEngine.Sprite sprite

Returns
UnityEngine.Texture2D

CropTexture(Texture, Rect)
Crops a Texture2D into a new Texture2D.
public static Texture2D CropTexture(this Texture texture, Rect source)
Parameters
UnityEngine.Texture texture

UnityEngine.Rect source

Returns
UnityEngine.Texture2D

LoadImage(Int32, Int32, Byte[])
Creates a new texture with no mimapping, linier colors, and calls texture.LoadImage(bytes), DontDestroyOnLoad(tex) and sets hideFlags = DontUnloadUnusedAsset | DontSaveInEditor. Old description no longer relevant as we've moved past version 2017. Loads an image from bytes with the specified width and height. Use this instead of someTexture.LoadImage() if you're compiling to an assembly. Unity has moved the method in 2017, and Unity's assembly updater is not able to fix it for you. This searches for a proper LoadImage method in multiple locations, and also handles type name conflicts.
public static Texture2D LoadImage(int width, int height, byte[] bytes)
Parameters
System.Int32 width

System.Int32 height

System.Byte[] bytes

Returns
UnityEngine.Texture2D

ResizeByBlit(Texture, Int32, Int32, FilterMode)
Resizes a texture by blitting, this allows you to resize unreadable textures.
public static Texture2D ResizeByBlit(this Texture texture, int width, int height, FilterMode filterMode)
Parameters
UnityEngine.Texture texture

System.Int32 width

System.Int32 height

UnityEngine.FilterMode filterMode

Returns
UnityEngine.Texture2D