Skip to content

API > Texture2D


Texture2D⚓︎

Texture2D inherits from Texture

Class that represents 2-dimensional texture.

Members⚓︎

Properties⚓︎

Name Description
Texture2D.alphaIsTransparencyProperty Indicates whether this texture was imported with TextureImporter.alphaIsTransparency enabled. This setting is available only in the Editor scripts. Note that changing this setting will have no effect; it must be enabled in TextureImporter instead.
Texture2D.calculatedMipmapLevelPropertyReadonly Property The mipmap level calculated by the streaming system, which takes into account the streaming Cameras and the location of the objects containing this Texture. This is unaffected by requestedMipmapLevel or minimumMipmapLevel.
Texture2D.desiredMipmapLevelPropertyReadonly Property The mipmap level that the streaming system would load before memory budgets are applied.
Texture2D.formatPropertyReadonly Property The format of the pixel data in the texture (Read Only). Use this to determine the format of the texture.
Texture2D.loadedMipmapLevelPropertyReadonly Property The mipmap level that is currently loaded by the streaming system.
Texture2D.loadingMipmapLevelPropertyReadonly Property The mipmap level that the mipmap streaming system is in the process of loading.
Texture2D.minimumMipmapLevelProperty Restricts the mipmap streaming system to a minimum mip level for this Texture.
Texture2D.requestedMipmapLevelProperty The mipmap level to load.
Texture2D.streamingMipmapsPropertyReadonly Property Determines whether mipmap streaming is enabled for this Texture.
Texture2D.streamingMipmapsPriorityPropertyReadonly Property Sets the relative priority for this Texture when reducing memory size to fit within the memory budget.
Texture2D.vtOnlyPropertyReadonly Property Returns true if the VTOnly checkbox was checked when the texture was imported; otherwise returns false. For additional information

Static Properties⚓︎

Name Description
Texture2D.blackTexture Static fieldPropertyReadonly Property Gets a small Texture with all black pixels. Unity sets all pixels of this Texture to transparent
Texture2D.grayTexture Static fieldPropertyReadonly Property Gets a small Texture with all gray pixels.
Texture2D.linearGrayTexture Static fieldPropertyReadonly Property Gets a small Texture with all gray pixels.
Texture2D.normalTexture Static fieldPropertyReadonly Property Gets a small Texture with pixels that represent surface normal vectors at a neutral position.
Texture2D.redTexture Static fieldPropertyReadonly Property Gets a small Texture with all red pixels.
Texture2D.whiteTexture Static fieldPropertyReadonly Property Gets a small Texture with all white pixels.

Constructor⚓︎

Name Description
Texture2D(width, height, textureFormat=TextureFormat.RGBA32, mipCount=-1, linear=false)Constructor Create a new empty texture.

Methods⚓︎

Name Description
Texture2D.Apply(updateMipmaps=true, makeNoLongerReadable=false) Method Copies changes you've made in a CPU texture to the GPU.
Texture2D.ClearMinimumMipmapLevel() Method Resets the minimumMipmapLevel field.
Texture2D.ClearRequestedMipmapLevel() Method Resets the requestedMipmapLevel field.
Texture2D.Compress(highQuality) Method Compress texture into DXT format.
Texture2D.GetPixel(x, y, mipLevel=0) Method Gets the pixel color at coordinates (x, y).
Texture2D.GetPixelBilinear(u, v, mipLevel=0) Method Gets the filtered pixel color at the normalized coordinates (u, v).
Texture2D.GetPixels(miplevel=0) Method Gets the pixel color data for a mipmap level as Color structs.
Texture2D.IsRequestedMipmapLevelLoaded() Method Checks to see whether the mipmap level set by requestedMipmapLevel has finished loading.
Texture2D.LoadRawTextureData(data[]) Method Sets the raw data of an entire texture in CPU memory.
Texture2D.LoadRawTextureData(data, size) Method Sets the raw data of an entire texture in CPU memory.
Texture2D.PackTextures(textures[], padding, maximumAtlasSize, makeNoLongerReadable) Method Packs multiple Textures into a texture atlas.
Texture2D.Resize(width, height) Method Resizes the texture.
Texture2D.Resize(width, height, format, hasMipMap) Method Resizes the texture.
Texture2D.SetPixel(x, y, color, mipLevel=0) Method Sets the pixel color at coordinates (x,y).
Texture2D.SetPixels(colors[], miplevel=0) Method Sets the pixel colors of an entire mipmap level.
Texture2D.UpdateExternalTexture(nativeTex) Method Updates Unity texture to use different native texture object.

Inherited Members⚓︎

Inherited Properties⚓︎

Name Description
Texture2D.anisoLevelProperty Defines the anisotropic filtering level of the Texture.
Texture2D.dimensionProperty Dimensionality (type) of the Texture (Read Only).
Texture2D.filterModeProperty Filtering mode of the texture.
Texture2D.heightProperty Height of the texture in pixels. (Read Only)
Texture2D.isReadableProperty Returns true if the Read/Write Enabled checkbox was checked when the texture was imported; otherwise returns false. For a dynamic Texture created from script, always returns true.
Texture2D.mipMapBiasProperty Mip map bias of the texture.
Texture2D.mipmapCountProperty How many mipmap levels are in this texture (Read Only).
Texture2D.updateCountProperty This counter is incremented when the texture is updated.
Texture2D.widthProperty Width of the texture in pixels. (Read Only)
Texture2D.wrapModeProperty Texture coordinate wrapping mode.
Texture2D.wrapModeUProperty Texture U coordinate wrapping mode.
Texture2D.wrapModeVProperty Texture V coordinate wrapping mode.
Texture2D.wrapModeWProperty Texture W coordinate wrapping mode for Texture3D.
Texture2D.hideFlagsProperty Should the object be hidden, saved with the Scene or modifiable by the user?
Texture2D.nameProperty The name of the object.

Inherited Methods⚓︎

Name Description
Texture2D.GetNativeTexturePtr()Method Retrieve a native (underlying graphics API) pointer to the Texture resource.
Texture2D.IncrementUpdateCount()Method Increment the update counter. Call this method when you update a Texture from the GPU side, or you want to explicitly increment the counter.
Texture2D.GetInstanceID()Method Returns the instance id of the object.