Show / Hide Table of Contents

Class Texture2D

Inheritance
Object
Object
Texture
Texture2D
Inherited Members
Texture.masterTextureLimit
Texture.anisotropicFiltering
Texture.SetGlobalAnisotropicFilteringLimits(Int32, Int32)
Texture.width
Texture.height
Texture.dimension
Texture.wrapMode
Texture.wrapModeU
Texture.wrapModeV
Texture.wrapModeW
Texture.filterMode
Texture.anisoLevel
Texture.mipMapBias
Texture.texelSize
Texture.GetNativeTexturePtr()
Texture.GetNativeTextureID()
Texture.updateCount
Texture.IncrementUpdateCount()
Texture.imageContentsHash
Texture.totalTextureMemory
Texture.desiredTextureMemory
Texture.targetTextureMemory
Texture.currentTextureMemory
Texture.nonStreamingTextureMemory
Texture.streamingMipmapUploadCount
Texture.streamingRendererCount
Texture.streamingTextureCount
Texture.nonStreamingTextureCount
Texture.streamingTexturePendingLoadCount
Texture.streamingTextureLoadingCount
Texture.SetStreamingTextureMaterialDebugProperties()
Texture.streamingTextureForceLoadAll
Texture.streamingTextureDiscardUnusedMips
Object.GetInstanceID()
Object.GetHashCode()
Object.Equals(Object)
Object.name
Object.Instantiate(Object, Vector3, Quaternion)
Object.Instantiate(Object, Vector3, Quaternion, Transform)
Object.Instantiate(Object)
Object.Instantiate(Object, Transform)
Object.Instantiate(Object, Transform, Boolean)
Object.Instantiate<T>(T)
Object.Instantiate<T>(T, Vector3, Quaternion)
Object.Instantiate<T>(T, Vector3, Quaternion, Transform)
Object.Instantiate<T>(T, Transform)
Object.Instantiate<T>(T, Transform, Boolean)
Object.Destroy(Object, Single)
Object.Destroy(Object)
Object.DestroyImmediate(Object, Boolean)
Object.DestroyImmediate(Object)
Object.FindObjectsOfType(Type)
Object.DontDestroyOnLoad(Object)
Object.hideFlags
Object.DestroyObject(Object, Single)
Object.DestroyObject(Object)
Object.FindSceneObjectsOfType(Type)
Object.FindObjectsOfTypeIncludingAssets(Type)
Object.FindObjectsOfType<T>()
Object.FindObjectOfType<T>()
Object.FindObjectsOfTypeAll(Type)
Object.FindObjectOfType(Type)
Object.ToString()
Object.Equals(Object, Object)
Object.ReferenceEquals(Object, Object)
Object.GetType()
Object.MemberwiseClone()
Namespace: UnityEngine
Assembly: UnityEngine.dll
Syntax
public sealed class Texture2D : Texture

Constructors

| Improve this Doc View Source

Texture2D(Int32, Int32)

Declaration
public Texture2D(int width, int height)
Parameters
Type Name Description
Int32 width
Int32 height
| Improve this Doc View Source

Texture2D(Int32, Int32, GraphicsFormat, TextureCreationFlags)

Declaration
public Texture2D(int width, int height, GraphicsFormat format, TextureCreationFlags flags)
Parameters
Type Name Description
Int32 width
Int32 height
GraphicsFormat format
TextureCreationFlags flags
| Improve this Doc View Source

Texture2D(Int32, Int32, TextureFormat, Boolean)

Declaration
public Texture2D(int width, int height, TextureFormat textureFormat, bool mipChain)
Parameters
Type Name Description
Int32 width
Int32 height
TextureFormat textureFormat
Boolean mipChain
| Improve this Doc View Source

Texture2D(Int32, Int32, TextureFormat, Boolean, Boolean)

Declaration
public Texture2D(int width, int height, [DefaultValue("TextureFormat.RGBA32")] TextureFormat textureFormat, [DefaultValue("true")] bool mipChain, [DefaultValue("false")] bool linear)
Parameters
Type Name Description
Int32 width
Int32 height
TextureFormat textureFormat
Boolean mipChain
Boolean linear

Properties

alphaIsTransparency

Declaration
public bool alphaIsTransparency { get; set; }
Property Value
Type Description
Boolean

blackTexture

Declaration
public static Texture2D blackTexture { get; }
Property Value
Type Description
Texture2D

desiredMipmapLevel

Declaration
public int desiredMipmapLevel { get; }
Property Value
Type Description
Int32

format

Declaration
public TextureFormat format { get; }
Property Value
Type Description
TextureFormat

isReadable

Declaration
public override bool isReadable { get; }
Property Value
Type Description
Boolean
Overrides
Texture.isReadable

loadedMipmapLevel

Declaration
public int loadedMipmapLevel { get; }
Property Value
Type Description
Int32

loadingMipmapLevel

Declaration
public int loadingMipmapLevel { get; }
Property Value
Type Description
Int32

mipmapCount

Declaration
public int mipmapCount { get; }
Property Value
Type Description
Int32

requestedMipmapLevel

Declaration
public int requestedMipmapLevel { get; set; }
Property Value
Type Description
Int32

streamingMipmaps

Declaration
public bool streamingMipmaps { get; }
Property Value
Type Description
Boolean

streamingMipmapsPriority

Declaration
public int streamingMipmapsPriority { get; }
Property Value
Type Description
Int32

whiteTexture

Declaration
public static Texture2D whiteTexture { get; }
Property Value
Type Description
Texture2D

Methods

| Improve this Doc View Source

Apply()

Declaration
public void Apply()
| Improve this Doc View Source

Apply(Boolean)

Declaration
public void Apply(bool updateMipmaps)
Parameters
Type Name Description
Boolean updateMipmaps
| Improve this Doc View Source

Apply(Boolean, Boolean)

Declaration
public void Apply([DefaultValue("true")] bool updateMipmaps, [DefaultValue("false")] bool makeNoLongerReadable)
Parameters
Type Name Description
Boolean updateMipmaps
Boolean makeNoLongerReadable

ClearRequestedMipmapLevel()

Declaration
public void ClearRequestedMipmapLevel()

Compress(Boolean)

Declaration
public void Compress(bool highQuality)
Parameters
Type Name Description
Boolean highQuality
| Improve this Doc View Source

CreateExternalTexture(Int32, Int32, TextureFormat, Boolean, Boolean, IntPtr)

Declaration
public static Texture2D CreateExternalTexture(int width, int height, TextureFormat format, bool mipChain, bool linear, IntPtr nativeTex)
Parameters
Type Name Description
Int32 width
Int32 height
TextureFormat format
Boolean mipChain
Boolean linear
IntPtr nativeTex
Returns
Type Description
Texture2D
| Improve this Doc View Source

GenerateAtlas(Vector2[], Int32, Int32, List<Rect>)

Declaration
public static bool GenerateAtlas(Vector2[] sizes, int padding, int atlasSize, List<Rect> results)
Parameters
Type Name Description
Vector2[] sizes
Int32 padding
Int32 atlasSize
List<Rect> results
Returns
Type Description
Boolean
| Improve this Doc View Source

GetPixel(Int32, Int32)

Declaration
public Color GetPixel(int x, int y)
Parameters
Type Name Description
Int32 x
Int32 y
Returns
Type Description
Color
| Improve this Doc View Source

GetPixelBilinear(Single, Single)

Declaration
public Color GetPixelBilinear(float x, float y)
Parameters
Type Name Description
Single x
Single y
Returns
Type Description
Color
| Improve this Doc View Source

GetPixels()

Declaration
public Color[] GetPixels()
Returns
Type Description
Color[]
| Improve this Doc View Source

GetPixels(Int32)

Declaration
public Color[] GetPixels(int miplevel)
Parameters
Type Name Description
Int32 miplevel
Returns
Type Description
Color[]
| Improve this Doc View Source

GetPixels(Int32, Int32, Int32, Int32)

Declaration
public Color[] GetPixels(int x, int y, int blockWidth, int blockHeight)
Parameters
Type Name Description
Int32 x
Int32 y
Int32 blockWidth
Int32 blockHeight
Returns
Type Description
Color[]

GetPixels(Int32, Int32, Int32, Int32, Int32)

Declaration
public Color[] GetPixels(int x, int y, int blockWidth, int blockHeight, int miplevel)
Parameters
Type Name Description
Int32 x
Int32 y
Int32 blockWidth
Int32 blockHeight
Int32 miplevel
Returns
Type Description
Color[]
| Improve this Doc View Source

GetPixels32()

Declaration
public Color32[] GetPixels32()
Returns
Type Description
Color32[]

GetPixels32(Int32)

Declaration
public Color32[] GetPixels32(int miplevel)
Parameters
Type Name Description
Int32 miplevel
Returns
Type Description
Color32[]

GetRawTextureData()

Declaration
public byte[] GetRawTextureData()
Returns
Type Description
Byte[]
| Improve this Doc View Source

GetRawTextureData<T>()

Declaration
public NativeArray<T> GetRawTextureData<T>()
    where T : struct
Returns
Type Description
NativeArray<T>
Type Parameters
Name Description
T

IsRequestedMipmapLevelLoaded()

Declaration
public bool IsRequestedMipmapLevelLoaded()
Returns
Type Description
Boolean
| Improve this Doc View Source

LoadRawTextureData(Byte[])

Declaration
public void LoadRawTextureData(byte[] data)
Parameters
Type Name Description
Byte[] data
| Improve this Doc View Source

LoadRawTextureData(IntPtr, Int32)

Declaration
public void LoadRawTextureData(IntPtr data, int size)
Parameters
Type Name Description
IntPtr data
Int32 size
| Improve this Doc View Source

LoadRawTextureData<T>(NativeArray<T>)

Declaration
public void LoadRawTextureData<T>(NativeArray<T> data)
    where T : struct
Parameters
Type Name Description
NativeArray<T> data
Type Parameters
Name Description
T
| Improve this Doc View Source

PackTextures(Texture2D[], Int32)

Declaration
public Rect[] PackTextures(Texture2D[] textures, int padding)
Parameters
Type Name Description
Texture2D[] textures
Int32 padding
Returns
Type Description
Rect[]
| Improve this Doc View Source

PackTextures(Texture2D[], Int32, Int32)

Declaration
public Rect[] PackTextures(Texture2D[] textures, int padding, int maximumAtlasSize)
Parameters
Type Name Description
Texture2D[] textures
Int32 padding
Int32 maximumAtlasSize
Returns
Type Description
Rect[]

PackTextures(Texture2D[], Int32, Int32, Boolean)

Declaration
public Rect[] PackTextures(Texture2D[] textures, int padding, int maximumAtlasSize, bool makeNoLongerReadable)
Parameters
Type Name Description
Texture2D[] textures
Int32 padding
Int32 maximumAtlasSize
Boolean makeNoLongerReadable
Returns
Type Description
Rect[]
| Improve this Doc View Source

ReadPixels(Rect, Int32, Int32)

Declaration
[ExcludeFromDocs]
public void ReadPixels(Rect source, int destX, int destY)
Parameters
Type Name Description
Rect source
Int32 destX
Int32 destY
| Improve this Doc View Source

ReadPixels(Rect, Int32, Int32, Boolean)

Declaration
public void ReadPixels(Rect source, int destX, int destY, [DefaultValue("true")] bool recalculateMipMaps)
Parameters
Type Name Description
Rect source
Int32 destX
Int32 destY
Boolean recalculateMipMaps
| Improve this Doc View Source

Resize(Int32, Int32)

Declaration
public bool Resize(int width, int height)
Parameters
Type Name Description
Int32 width
Int32 height
Returns
Type Description
Boolean
| Improve this Doc View Source

Resize(Int32, Int32, TextureFormat, Boolean)

Declaration
public bool Resize(int width, int height, TextureFormat format, bool hasMipMap)
Parameters
Type Name Description
Int32 width
Int32 height
TextureFormat format
Boolean hasMipMap
Returns
Type Description
Boolean
| Improve this Doc View Source

SetPixel(Int32, Int32, Color)

Declaration
public void SetPixel(int x, int y, Color color)
Parameters
Type Name Description
Int32 x
Int32 y
Color color
| Improve this Doc View Source

SetPixels(Int32, Int32, Int32, Int32, Color[])

Declaration
public void SetPixels(int x, int y, int blockWidth, int blockHeight, Color[] colors)
Parameters
Type Name Description
Int32 x
Int32 y
Int32 blockWidth
Int32 blockHeight
Color[] colors
| Improve this Doc View Source

SetPixels(Int32, Int32, Int32, Int32, Color[], Int32)

Declaration
public void SetPixels(int x, int y, int blockWidth, int blockHeight, Color[] colors, [DefaultValue("0")] int miplevel)
Parameters
Type Name Description
Int32 x
Int32 y
Int32 blockWidth
Int32 blockHeight
Color[] colors
Int32 miplevel
| Improve this Doc View Source

SetPixels(Color[])

Declaration
public void SetPixels(Color[] colors)
Parameters
Type Name Description
Color[] colors
| Improve this Doc View Source

SetPixels(Color[], Int32)

Declaration
public void SetPixels(Color[] colors, [DefaultValue("0")] int miplevel)
Parameters
Type Name Description
Color[] colors
Int32 miplevel
| Improve this Doc View Source

SetPixels32(Int32, Int32, Int32, Int32, Color32[])

Declaration
public void SetPixels32(int x, int y, int blockWidth, int blockHeight, Color32[] colors)
Parameters
Type Name Description
Int32 x
Int32 y
Int32 blockWidth
Int32 blockHeight
Color32[] colors
| Improve this Doc View Source

SetPixels32(Int32, Int32, Int32, Int32, Color32[], Int32)

Declaration
public void SetPixels32(int x, int y, int blockWidth, int blockHeight, Color32[] colors, int miplevel)
Parameters
Type Name Description
Int32 x
Int32 y
Int32 blockWidth
Int32 blockHeight
Color32[] colors
Int32 miplevel
| Improve this Doc View Source

SetPixels32(Color32[])

Declaration
public void SetPixels32(Color32[] colors)
Parameters
Type Name Description
Color32[] colors
| Improve this Doc View Source

SetPixels32(Color32[], Int32)

Declaration
public void SetPixels32(Color32[] colors, int miplevel)
Parameters
Type Name Description
Color32[] colors
Int32 miplevel

UpdateExternalTexture(IntPtr)

Declaration
public void UpdateExternalTexture(IntPtr nativeTex)
Parameters
Type Name Description
IntPtr nativeTex

Extension Methods

ImageConversion.EncodeToTGA(Texture2D)
ImageConversion.EncodeToPNG(Texture2D)
ImageConversion.EncodeToJPG(Texture2D, Int32)
ImageConversion.EncodeToJPG(Texture2D)
ImageConversion.EncodeToEXR(Texture2D, Texture2D.EXRFlags)
ImageConversion.EncodeToEXR(Texture2D)
ImageConversion.LoadImage(Texture2D, Byte[], Boolean)
ImageConversion.LoadImage(Texture2D, Byte[])
MustExtensions.MustBeEqual<T>(T, T)
MustExtensions.MustBeEqual<T>(T, T, String)
MustExtensions.MustNotBeEqual<T>(T, T)
MustExtensions.MustNotBeEqual<T>(T, T, String)
MustExtensions.MustBeNull<T>(T)
MustExtensions.MustBeNull<T>(T, String)
MustExtensions.MustNotBeNull<T>(T)
MustExtensions.MustNotBeNull<T>(T, String)
  • Improve this Doc
  • View Source
Back to top Generated by DocFX