Version 3.1.11.0

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[])
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