C# Класс UnityEngine.Texture2D

Наследование: Texture
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
Compress ( bool highQuality ) : void

Compress texture into DXT format.

CreateExternalTexture ( int width, int height, TextureFormat format, bool mipmap, bool linear, IntPtr nativeTex ) : Texture2D

Creates Unity Texture out of externally created native texture object.

EncodeToJPG ( ) : byte[]

Encodes this texture into JPG format.

GetPixel ( int x, int y ) : Color

Returns pixel color at coordinates (x, y).

GetPixelBilinear ( float u, float v ) : Color

Returns filtered pixel color at normalized coordinates (u, v).

GetPixels ( [ miplevel ) : UnityEngine.Color[]

Get the pixel colors from the texture.

LoadRawTextureData ( IntPtr data, int size ) : void

Fills texture pixels with raw preformatted data.

LoadRawTextureData ( byte data ) : void

Fills texture pixels with raw preformatted data.

ReadPixels ( Rect source, int destX, int destY, [ recalculateMipMaps ) : void

Read pixels from screen into the saved texture data.

Resize ( int width, int height ) : bool

Resizes the texture.

SetPixel ( int x, int y, Color color ) : void

Sets pixel color at coordinates (x,y).

SetPixels ( Color colors, [ miplevel ) : void

Set a block of pixel colors.

SetPixels32 ( Color32 colors, [ miplevel ) : void

Set a block of pixel colors.

SetPixels32 ( int x, int y, int blockWidth, int blockHeight, Color32 colors, [ miplevel ) : void

Set a block of pixel colors.

Texture2D ( int width, int height ) : System

Create a new empty texture.

Texture2D ( int width, int height, TextureFormat format, bool mipmap ) : System

Create a new empty texture.

Texture2D ( int width, int height, TextureFormat format, bool mipmap, bool linear ) : System

See Also: SetPixel, SetPixels, Apply functions.

Приватные методы

Метод Описание
Apply ( ) : void
Apply ( [ updateMipmaps, [ makeNoLongerReadable ) : void
Apply ( bool updateMipmaps ) : void
EncodeToJPG ( int quality ) : byte[]
EncodeToPNG ( ) : byte[]
GetPixels ( ) : UnityEngine.Color[]
GetPixels ( int x, int y, int blockWidth, int blockHeight ) : UnityEngine.Color[]
GetPixels ( int x, int y, int blockWidth, int blockHeight, [ miplevel ) : UnityEngine.Color[]
GetPixels32 ( ) : UnityEngine.Color32[]
GetPixels32 ( [ miplevel ) : UnityEngine.Color32[]
GetRawTextureData ( ) : byte[]
INTERNAL_CALL_Compress ( Texture2D self, bool highQuality ) : void
INTERNAL_CALL_GetPixel ( Texture2D self, int x, int y, Color &value ) : void
INTERNAL_CALL_GetPixelBilinear ( Texture2D self, float u, float v, Color &value ) : void
INTERNAL_CALL_ReadPixels ( Texture2D self, Rect &source, int destX, int destY, bool recalculateMipMaps ) : void
INTERNAL_CALL_SetPixel ( Texture2D self, int x, int y, Color &color ) : void
Internal_Create ( [ mono, int width, int height, TextureFormat format, bool mipmap, bool linear, IntPtr nativeTex ) : void
Internal_ResizeWH ( int width, int height ) : bool
LoadImage ( byte data ) : bool
LoadImage ( byte data, [ markNonReadable ) : bool
LoadRawTextureData_ImplArray ( byte data ) : void
LoadRawTextureData_ImplPointer ( IntPtr data, int size ) : void
PackTextures ( Texture2D textures, int padding ) : UnityEngine.Rect[]
PackTextures ( Texture2D textures, int padding, [ maximumAtlasSize, [ makeNoLongerReadable ) : UnityEngine.Rect[]
PackTextures ( Texture2D textures, int padding, int maximumAtlasSize ) : UnityEngine.Rect[]
ReadPixels ( Rect source, int destX, int destY ) : void
Resize ( int width, int height, TextureFormat format, bool hasMipMap ) : bool
SetAllPixels32 ( Color32 colors, int miplevel ) : void
SetBlockOfPixels32 ( int x, int y, int blockWidth, int blockHeight, Color32 colors, int miplevel ) : void
SetPixels ( Color colors ) : void
SetPixels ( int x, int y, int blockWidth, int blockHeight, Color colors ) : void
SetPixels ( int x, int y, int blockWidth, int blockHeight, Color colors, [ miplevel ) : void
SetPixels32 ( Color32 colors ) : void
SetPixels32 ( int x, int y, int blockWidth, int blockHeight, Color32 colors ) : void
Texture2D ( int width, int height, TextureFormat format, bool mipmap, bool linear, IntPtr nativeTex ) : System
UpdateExternalTexture ( IntPtr nativeTex ) : void

Описание методов

Compress() публичный Метод

Compress texture into DXT format.

public Compress ( bool highQuality ) : void
highQuality bool
Результат void

CreateExternalTexture() публичный статический Метод

Creates Unity Texture out of externally created native texture object.

public static CreateExternalTexture ( int width, int height, TextureFormat format, bool mipmap, bool linear, IntPtr nativeTex ) : Texture2D
width int Width of texture in pixels.
height int Height of texture in pixels.
format TextureFormat Format of underlying texture object.
mipmap bool Does the texture have mipmaps?
linear bool Is texture using linear color space?
nativeTex IntPtr Native 2D texture object.
Результат Texture2D

EncodeToJPG() публичный Метод

Encodes this texture into JPG format.

public EncodeToJPG ( ) : byte[]
Результат byte[]

GetPixel() публичный Метод

Returns pixel color at coordinates (x, y).

public GetPixel ( int x, int y ) : Color
x int
y int
Результат Color

GetPixelBilinear() публичный Метод

Returns filtered pixel color at normalized coordinates (u, v).

public GetPixelBilinear ( float u, float v ) : Color
u float
v float
Результат Color

GetPixels() публичный Метод

Get the pixel colors from the texture.

public GetPixels ( [ miplevel ) : UnityEngine.Color[]
miplevel [ The mipmap level to fetch the pixels from. Defaults to zero.
Результат UnityEngine.Color[]

LoadRawTextureData() публичный Метод

Fills texture pixels with raw preformatted data.

public LoadRawTextureData ( IntPtr data, int size ) : void
data IntPtr Byte array to initialize texture pixels with.
size int Size of data in bytes.
Результат void

LoadRawTextureData() публичный Метод

Fills texture pixels with raw preformatted data.

public LoadRawTextureData ( byte data ) : void
data byte Byte array to initialize texture pixels with.
Результат void

ReadPixels() публичный Метод

Read pixels from screen into the saved texture data.

public ReadPixels ( Rect source, int destX, int destY, [ recalculateMipMaps ) : void
source Rect Rectangular region of the view to read from. Pixels are read from current render target.
destX int Horizontal pixel position in the texture to place the pixels that are read.
destY int Vertical pixel position in the texture to place the pixels that are read.
recalculateMipMaps [ Should the texture's mipmaps be recalculated after reading?
Результат void

Resize() публичный Метод

Resizes the texture.

public Resize ( int width, int height ) : bool
width int
height int
Результат bool

SetPixel() публичный Метод

Sets pixel color at coordinates (x,y).

public SetPixel ( int x, int y, Color color ) : void
x int
y int
color Color
Результат void

SetPixels() публичный Метод

Set a block of pixel colors.

public SetPixels ( Color colors, [ miplevel ) : void
colors Color The array of pixel colours to assign (a 2D image flattened to a 1D array).
miplevel [ The mip level of the texture to write to.
Результат void

SetPixels32() публичный Метод

Set a block of pixel colors.

public SetPixels32 ( Color32 colors, [ miplevel ) : void
colors Color32
miplevel [
Результат void

SetPixels32() публичный Метод

Set a block of pixel colors.

public SetPixels32 ( int x, int y, int blockWidth, int blockHeight, Color32 colors, [ miplevel ) : void
x int
y int
blockWidth int
blockHeight int
colors Color32
miplevel [
Результат void

Texture2D() публичный Метод

Create a new empty texture.

public Texture2D ( int width, int height ) : System
width int
height int
Результат System

Texture2D() публичный Метод

Create a new empty texture.

public Texture2D ( int width, int height, TextureFormat format, bool mipmap ) : System
width int
height int
format TextureFormat
mipmap bool
Результат System

Texture2D() публичный Метод

See Also: SetPixel, SetPixels, Apply functions.

public Texture2D ( int width, int height, TextureFormat format, bool mipmap, bool linear ) : System
width int
height int
format TextureFormat
mipmap bool
linear bool
Результат System