attachment.width

Type: number (read/write)
Attachment types: region, mesh

Overview

The base width of the attachment in Spine units.

For region attachments, this is the width of the rectangular image quad before scaling is applied.

For mesh attachments, this is non-essential data from the Spine editor: the mesh is drawn from its vertices, so writing width changes nothing on screen.

For region attachments, setting this property updates the attachment’s geometry at once: the next skeleton:draw() shows the change.

Example

local slot = skeleton:findSlot("gun")
local attachment = slot.attachment

if attachment and attachment.type == "region" then
    -- Get current dimensions
    print("Size:", attachment.width, "x", attachment.height)

    -- Make it wider
    attachment.width = attachment.width * 1.5

    -- Set specific size
    attachment.width = 100
    attachment.height = 50
end

Notes

  • For a region, combines with scaleX to determine final width: finalWidth = width * scaleX

  • Changing width does not automatically update UV coordinates

  • Returns nil for attachment types that don’t have width

See also