Skip to main content
Version: 0.12.0 (latest)

UeTexture

A texture wrapper class for GameMaker that supports UV transformations, wrapping modes, tiling, flipping, rotation, filtering, and mipmap generation. Transforms are baked into a surface and converted into a GPU-ready sprite.

Constructor​

new UeTexture(sprite = undefined, data = {})

Data parameters​

KeyTypeDefaultDescription
repeatbooleantrueWhether the texture repeats
filterbooleantrueEnables texture smoothing
generateMipmapsbooleantrueWhether to enable mipmaps for minification

Properties​

NameTypeDescription
idrealIncremental object ID (auto-generated)
spritespriteA sprite resource
isTexturetrueIdentifies this as a texture.
type"Texture"Constant string.
uuidstringUnique texture ID.
namestringOptional name.
imagespriteBase image sprite.
offsetUeVector2UV offset.
repeatUeVector2UV repeat count.
centerUeVector2Pivot point for transforms.
rotationrealRotation in degrees (Z-axis).
flipXbooleanFlips horizontally.
flipYbooleanFlips vertically.
wrapSbooleanHorizontal wrapping (UE_TEXTURE_WRAP.REPEAT, UE_TEXTURE_WRAP.CLAMP_TO_EDGE, UE_TEXTURE_WRAP.MIRRORED_REPEAT).
wrapTbooleanVertical wrapping
filterbooleanTexture filtering mode.
generateMipmapsrealEnables mipmap generation (default mip_markedonly).
matrixUeMatrix4UV transformation matrix.
matrixAutoUpdatebooleanAuto-updates matrix when needed.
needsUpdatebooleanMarks texture as needing rebake.
userDatastructCustom user data

🧩 Methods​

MethodDescription
updateMatrix()Rebuilds the internal UV transformation matrix using offset, repeat, center, rotation, flipX, and flipY.
update()Rebake the texture sprite based on the matrix and texture props. This is done automatically when matrixAutoUpdate is thruthy
dispose()Frees any GPU resources (like the cached sprite and texture). Should be called before replacing or destroying the texture.
toJSON()Returns a plain JSON-like struct containing all the serializable parameters (wrap, repeat, filter, etc.).
contain(aspect)Scales the texture to fit entirely within the surface without cropping or stretching. Preserves the original aspect ratio. Similar to CSS
object-fit: contain.
cover(aspect)Scales the texture to completely cover the surface, potentially cropping parts of it. Preserves the original aspect ratio. Similar to CSS object-fit: cover.
fill()Resets the texture transform to fill the surface entirely, ignoring aspect ratio. Similar to CSS object-fit: fill.
clone()Returns a deep clone of this texture.
export(fname)Exports the texture sprite to a file.
import(fname)Imports a texture sprite from a file.
fromJSON(data)Loads texture properties from a JSON object.

Notes​

You don't need to call updateMatrix() manually unless matrixAutoUpdate is set to false. Just set needsUpdate = true to tells the engine to rebake the texture.