Texture2D
class in UnityEngine · UnityEngine.CoreModule · inherits from Texture
A 2D texture. Pixels live in managed memory as RGBA32 (whatever format says) with row 0 at the bottom, as in Unity; Apply uploads them to the GPU.
Constructors 1
Texture2D(int width, int height)Texture2D(int width, int height, TextureFormat textureFormat, bool mipChain)Texture2D(int width, int height, TextureFormat textureFormat, bool mipChain, bool linear)Texture2D(int width, int height, TextureFormat textureFormat, int mipCount, bool linear)Properties 10
static Texture2D blackTexture { get; }TextureFormat format { get; }static Texture2D grayTexture { get; }int height { get; set; }bool isDataSRGB { get; }bool isReadable { get; }int mipmapCount { get; }The full chain goes down to 1x1.
static Texture2D redTexture { get; }static Texture2D whiteTexture { get; }int width { get; set; }Methods 12
void Apply(bool updateMipmaps = true, bool makeNoLongerReadable = false)void Apply(bool updateMipmaps)void Apply()Color GetPixelBilinear(float u, float v)Color GetPixelBilinear(float u, float v, int mipLevel)Bilinear sample at normalized (u, v). Unity samples at u * width without a half-texel offset (recorded in rendering_2d).
Color[] GetPixels()Color[] GetPixels(int miplevel)Color[] GetPixels(int x, int y, int blockWidth, int blockHeight)byte[] GetRawTextureData()void LoadRawTextureData(byte[] data)void ReadPixels(Rect source, int destX, int destY, bool recalculateMipMaps = true)void ReadPixels(Rect source, int destX, int destY)Reading back the screen or a render texture isn't supported yet: the texture's pixels are left as they were (said once).
bool Reinitialize(int width, int height)bool Reinitialize(int width, int height, TextureFormat format, bool hasMipMap)Resizes, discarding the contents.
Not in Tassix yet 26
ClearMinimumMipmapLevel ClearRequestedMipmapLevel Compress CopyPixels CreateExternalTexture GenerateAtlas GetPixelData IsRequestedMipmapLevelLoaded PackTextures SetPixelData UpdateExternalTexture activeMipmapLimit alphaIsTransparency calculatedMipmapLevel desiredMipmapLevel ignoreMipmapLimit linearGrayTexture loadedMipmapLevel loadingMipmapLevel minimumMipmapLevel mipmapLimitGroup normalTexture requestedMipmapLevel streamingMipmaps streamingMipmapsPriority vtOnly
Checked against Unity
Conformance scenarios that exercise it, recorded in Unity and compared event by event.