Texture2DArray

Struct Texture2DArray 

Source
pub struct Texture2DArray {
Show 16 fields pub m_ColorSpace: i32, pub m_DataSize: u32, pub m_Depth: i32, pub m_Format: i32, pub m_Height: i32, pub m_IsReadable: bool, pub m_MipCount: i32, pub m_Name: String, pub m_TextureSettings: GLTextureSettings, pub m_Width: i32, pub image_data: Option<Vec<u8>>, pub m_DownscaleFallback: Option<bool>, pub m_ForcedFallbackFormat: Option<i32>, pub m_IsAlphaChannelOptional: Option<bool>, pub m_StreamData: Option<StreamingInfo>, pub m_UsageMode: Option<i32>,
}
Expand description

Texture2DArray is a class of the Unity engine since version 5.4.0f3. Exert from Unity’s scripting documentation: Class for handling 2D texture arrays. Modern graphics APIs (e.g. D3D10 and later, OpenGL ES 3.0 and later, Metal etc.) support “texture arrays”, which is an array of same size & format textures.

From the shader side, they are treated as a single resource, and sampling them needs an extra coordinate that indicates which array element to sample from.Typically texture arrays are useful as an alternative for texture atlases, or in other cases where objects use a set of same-sized textures (e.g. terrains).Currently in Unity texture arrays do not have an import pipeline for them, and must be created from code, either at runtime or in editor scripts.

Using Graphics.CopyTexture is useful for fast copying of pixel data from regular 2D textures into elements of a texture array. From editor scripts,

a common way of creating serialized texture array is to create it, fill with data (either via Graphics.CopyTexture from regular 2D textures, or via SetPixels or

SetPixels32) and save it as an asset via AssetDatabase.CreateAsset.Note that not all platforms and GPUs support texture arrays; for example Direct3D9 and OpenGL ES 2.0 do not. Use SystemInfo.supports2DArrayTextures to check. Also, this class does not support Texture2DArray creation with a Crunch compression TextureFormat.

Fields§

§m_ColorSpace: i32§m_DataSize: u32§m_Depth: i32

Number of elements in a texture array (Read Only).

§m_Format: i32

Texture format (Read Only).

§m_Height: i32

Height of the Texture in pixels (Read Only).

§m_IsReadable: bool

Whether Unity stores an additional copy of this texture’s pixel data in CPU-addressable memory.

§m_MipCount: i32§m_Name: String

The name of the object.

§m_TextureSettings: GLTextureSettings§m_Width: i32

Width of the Texture in pixels (Read Only).

§image_data: Option<Vec<u8>>

Vec: (5.4.0f3 - 2022.3.2f1)

§m_DownscaleFallback: Option<bool>

bool: (2017.3.0b1 - 2022.3.2f1)

§m_ForcedFallbackFormat: Option<i32>

i32: (2017.3.0b1 - 2022.3.2f1)

§m_IsAlphaChannelOptional: Option<bool>

bool: (2020.2.0b1 - 2022.3.2f1)

§m_StreamData: Option<StreamingInfo>

StreamingInfo: (5.6.0b1 - 2022.3.2f1)

§m_UsageMode: Option<i32>

i32: (2020.2.0b1 - 2022.3.2f1)

Trait Implementations§

Source§

impl Debug for Texture2DArray

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Texture2DArray

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for Texture2DArray

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,