Skip to content

Format

typescript
Texture.width

class: Texture

Description

The width of the texture in pixels.

The width of the texture represents the number of pixels in the horizontal direction. Read-only.

Parameters

param_nametypedescription

Return

typedescription
numberThe width of the texture.

Code Example

typescript
let uuid = "31A9092E126B4B19BBFD9D5FCD75AA49";
let tex = Resources.Load<Texture>(Texture, uuid);
if (tex == null) {
    throw new Exception("failed to load texture2d: " + uuid);
}
Debug.Log("Texture width is: ", tex.width);