Texture2D
info
Texture2D inherits from Texture
Class that represents 2-dimensional texture.
Members
Properties
Name | Description |
---|---|
Texture2D .alphaIsTransparency | 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 .calculatedMipmapLevel | 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 .desiredMipmapLevel | The mipmap level that the streaming system would load before memory budgets are applied. |
Texture2D .format | The format of the pixel data in the texture (Read Only). Use this to determine the format of the texture. |
Texture2D .loadedMipmapLevel | The mipmap level that is currently loaded by the streaming system. |
Texture2D .loadingMipmapLevel | The mipmap level that the mipmap streaming system is in the process of loading. |
Texture2D .minimumMipmapLevel | Restricts the mipmap streaming system to a minimum mip level for this Texture. |
Texture2D .requestedMipmapLevel | The mipmap level to load. |
Texture2D .streamingMipmaps | Determines whether mipmap streaming is enabled for this Texture. |
Texture2D .streamingMipmapsPriority | Sets the relative priority for this Texture when reducing memory size to fit within the memory budget. |
Texture2D .vtOnly | 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 | Gets a small Texture with all black pixels. Unity sets all pixels of this Texture to transparent |
Texture2D .grayTexture | Gets a small Texture with all gray pixels. |
Texture2D .linearGrayTexture | Gets a small Texture with all gray pixels. |
Texture2D .normalTexture | Gets a small Texture with pixels that represent surface normal vectors at a neutral position. |
Texture2D .redTexture | Gets a small Texture with all red pixels. |
Texture2D .whiteTexture | Gets a small Texture with all white pixels. |
Constructor
Name | Description |
---|---|
Texture2D(width, height, textureFormat=TextureFormat.RGBA32, mipCount=-1, linear=false) | Create a new empty texture. |
Methods
Name | Description |
---|---|
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
Name | Description |
---|---|
Texture2D .anisoLevel | Defines the anisotropic filtering level of the Texture. |
Texture2D .dimension | Dimensionality (type) of the Texture (Read Only). |
Texture2D .filterMode | Filtering mode of the texture. |
Texture2D .height | Height of the texture in pixels. (Read Only) |
Texture2D .isReadable | 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 .mipMapBias | Mip map bias of the texture. |
Texture2D .mipmapCount | How many mipmap levels are in this texture (Read Only). |
Texture2D .updateCount | This counter is incremented when the texture is updated. |
Texture2D .width | Width of the texture in pixels. (Read Only) |
Texture2D .wrapMode | Texture coordinate wrapping mode. |
Texture2D .wrapModeU | Texture U coordinate wrapping mode. |
Texture2D .wrapModeV | Texture V coordinate wrapping mode. |
Texture2D .wrapModeW | Texture W coordinate wrapping mode for Texture3D. |
Texture2D .hideFlags | Should the object be hidden, saved with the Scene or modifiable by the user? |
Texture2D .name | The name of the object. |
Inherited Methods
Name | Description |
---|---|
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. |