Skip to main content

Texture2D

info

Texture2D inherits from Texture

Class that represents 2-dimensional texture.

Members

Properties

NameDescription
Texture2D.alphaIsTransparencyIndicates 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.calculatedMipmapLevelThe 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.desiredMipmapLevelThe mipmap level that the streaming system would load before memory budgets are applied.
Texture2D.formatThe format of the pixel data in the texture (Read Only). Use this to determine the format of the texture.
Texture2D.loadedMipmapLevelThe mipmap level that is currently loaded by the streaming system.
Texture2D.loadingMipmapLevelThe mipmap level that the mipmap streaming system is in the process of loading.
Texture2D.minimumMipmapLevelRestricts the mipmap streaming system to a minimum mip level for this Texture.
Texture2D.requestedMipmapLevelThe mipmap level to load.
Texture2D.streamingMipmapsDetermines whether mipmap streaming is enabled for this Texture.
Texture2D.streamingMipmapsPrioritySets the relative priority for this Texture when reducing memory size to fit within the memory budget.
Texture2D.vtOnlyReturns true if the VTOnly checkbox was checked when the texture was imported; otherwise returns false. For additional information

Static Properties

NameDescription
Texture2D.blackTextureGets a small Texture with all black pixels. Unity sets all pixels of this Texture to transparent
Texture2D.grayTextureGets a small Texture with all gray pixels.
Texture2D.linearGrayTextureGets a small Texture with all gray pixels.
Texture2D.normalTextureGets a small Texture with pixels that represent surface normal vectors at a neutral position.
Texture2D.redTextureGets a small Texture with all red pixels.
Texture2D.whiteTextureGets a small Texture with all white pixels.

Constructor

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

Methods

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

Inherited Members

Inherited Properties

NameDescription
Texture2D.anisoLevelDefines the anisotropic filtering level of the Texture.
Texture2D.dimensionDimensionality (type) of the Texture (Read Only).
Texture2D.filterModeFiltering mode of the texture.
Texture2D.heightHeight of the texture in pixels. (Read Only)
Texture2D.isReadableReturns 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.mipMapBiasMip map bias of the texture.
Texture2D.mipmapCountHow many mipmap levels are in this texture (Read Only).
Texture2D.updateCountThis counter is incremented when the texture is updated.
Texture2D.widthWidth of the texture in pixels. (Read Only)
Texture2D.wrapModeTexture coordinate wrapping mode.
Texture2D.wrapModeUTexture U coordinate wrapping mode.
Texture2D.wrapModeVTexture V coordinate wrapping mode.
Texture2D.wrapModeWTexture W coordinate wrapping mode for Texture3D.
Texture2D.hideFlagsShould the object be hidden, saved with the Scene or modifiable by the user?
Texture2D.nameThe name of the object.

Inherited Methods

NameDescription
Texture2D.GetNativeTexturePtr()Retrieve a native (underlying graphics API) pointer to the Texture resource.
Texture2D.IncrementUpdateCount()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()Returns the instance id of the object.