TextureBase:SetTexture
TextureBase:GetTexture |
||
TextureBase:GetTextureFileID |
||
TextureBase:GetTextureFilePath |
||
TextureBase:SetTexture |
||
TextureBase:SetColorTexture |
Sets the texture to an image.
TextureBase:SetTexture([textureAsset, wrapModeHorizontal, wrapModeVertical, filterMode])
Arguments
To clear the texture call this without any params or nil
.
- textureAsset
- number|string? - A FileID or the file path to a texture.
- wrapModeHorizontal
- string?
= CLAMP
- If SetHorizTile is enabled, sets the wrap behavior for pixels with an x coordinate outside the (0, 1) region of the texture coordinate space.
- wrapModeVertical
- string?
= CLAMP
- If SetVertTile is enabled, sets the wrap behavior for pixels with a y coordinate outside the (0, 1) region of the texture coordinate space.
wrapMode Description CLAMP
Default; extends the texture edges infinitely. CLAMPTOWHITE
Fills the overflow with white. CLAMPTOBLACK
Fills the overflow with black. CLAMPTOBLACKADDITIVE
Fills overflow with a transparent black. REPEAT
(ortrue
)Repeats the whole texture infinitely. MIRROR
Repeats the whole texture infinitely, mirroring adjacent iterations.
- filterMode
- string?
= LINEAR
filterMode Description LINEAR
Default; bilinear filtering. TRILINEAR
Also sampling mipmaps. NEAREST
Nearest-neighbor filtering.
Details
- Custom images must be in BLP, JPEG, PNG, or TGA format with power-of-two dimensions (e.g. 16x16, 8x32, 256x64). TGA images may have 8bpp grayscale, 24bpp RGB, or 32 bpp RGBA; RLE is supported.
- Unlike other formats, PNG files must explicitly include the ".png" extension when their file path is used in-game.
- Pixels outside the texture coordinate space may be sampled explicitly by SetTexCoord, or implicitly by the tiling mechanism when the texture widget is larger than the default size of the texture file.
- Textures load asynchronously. For example,
texture:GetSize()
returns 0,0 until IsObjectLoaded becomestrue
; and then it returns the native texture size. See also TextureLoadingGroupMixin:IsFullyLoaded. - This API has a
success
return value but it has no significance since it always returnstrue
, even for invalid FileIDs or parameters.
Example
Shows an icon on the screen.
local tex = UIParent:CreateTexture()
tex:SetPoint("CENTER")
tex:SetTexture(134532) -- interface/icons/inv_mushroom_11
|
The texture will be stretched or compressed if tiling is disabled.
tex:SetTexture("Interface/ContainerFrame/UI-Icon-QuestBang")
tex:SetSize(256, 64)
tex:SetTexture("Interface/ContainerFrame/UI-Icon-QuestBang")
tex:SetSize(32, 64)
|
Wrap Mode
When tiling is enabled, wrap mode specifies how pixels outside the texture coordinate space will be handled.
CLAMP - If the wrap mode is omitted it defaults to clamp.
tex:SetTexture("Interface/ContainerFrame/UI-Icon-QuestBang")
tex:SetSize(256, 64)
tex:SetHorizTile(true)
Clamping extends the texture edges infinitely. This texture illustrates how the right and bottom edges and the bottomright pixel get extended. tex:SetTexture("Interface/RAIDFRAME/Shield-Overlay", "CLAMP", "CLAMP")
tex:SetSize(64, 64)
tex:SetScale(2)
tex:SetHorizTile(true)
tex:SetVertTile(true)
|
CLAMPTOWHITE - Fills everything outside the texture coordinate space with opaque white.
tex:SetTexture("Interface/ContainerFrame/UI-Icon-QuestBang", "CLAMPTOWHITE")
tex:SetSize(256, 64)
tex:SetHorizTile(true)
|
CLAMPTOBLACK - Fills everything outside the texture coordinate space with opaque black.
tex:SetTexture("Interface/ContainerFrame/UI-Icon-QuestBang", "CLAMPTOBLACK")
tex:SetSize(256, 64)
tex:SetHorizTile(true)
|
CLAMPTOBLACKADDITIVE - Additive clamping to black means every pixel that is outside the unit square containing the original texture is filled with transparent black pixels (R=G=B=A=0) . The transparent pixels being black can matter in specific situations where the AlphaMode ignores the alpha channel.
tex:SetTexture("Interface/Buttons/YELLOWORANGE64", "CLAMPTOBLACKADDITIVE")
tex:SetSize(128, 64)
tex:SetHorizTile(true)
|
REPEAT - Sets the wrapMode to repeat horizontally.
tex:SetTexture("Interface/ContainerFrame/UI-Icon-QuestBang", "REPEAT")
tex:SetSize(256, 64)
tex:SetHorizTile(true)
Repeats horizontally and vertically tex:SetTexture("Interface/ContainerFrame/UI-Icon-QuestBang", "REPEAT", "REPEAT")
tex:SetSize(128, 128)
tex:SetHorizTile(true)
tex:SetVertTile(true)
|
MIRROR - Sets the wrapMode to mirror vertically.
tex:SetTexture("Interface/ContainerFrame/UI-Icon-QuestBang", "MIRROR")
tex:SetSize(128, 64)
tex:SetHorizTile(true)
|
Patch changes
Patch 10.0.7 (2023-03-21): Added PNG texture format support.
Patch 9.0.1 (2020-10-13): New files located in the Interface/AddOns/ directory tree no longer require a client restart to take effect, only a /reload.
Patch 8.0.1 (2018-07-17): Added filterMode
argument.
Patch 7.3.5 (2018-01-16): Changed . As of Dragonflight this seems to be no longer the case. horizWrap
to apply horizontally and vertically, ignoring vertWrap
Patch 7.0.3 (2016-07-19): Solid-color variant replaced with TextureBase:SetColorTexture.
Patch 4.0.3a (2010-11-23): Changed the return value to always return true
; no longer indicating success.
Patch 1.10.0 (2006-03-28): Added success
return value.[1]
References
- ^ slouken 2006-02-09. Re: Upcoming 1.10 Changes - Concise List. Archived from the original