按源仓库内容呈现,保留标题、案例、代码、表格、链接以及原文引用的演示图片。
MSW Sprite RUID
Rules for assigning a RUID to SpriteRendererComponent.SpriteRUID (world) or SpriteGUIRendererComponent.ImageRUID (UI).
Native type support
Both components accept a sprite or animationclip RUID directly — no extra animator component required.
| Component | Property | Value form (runtime .mlua) | Native RUID types |
|---|---|---|---|
SpriteRendererComponent (world) | SpriteRUID | plain string | sprite, animationclip |
SpriteGUIRendererComponent (UI) | ImageRUID | DataRef("...") | sprite, animationclip |
ImageRUID is a DataRef: in runtime .mlua, assign DataRef(ruid). Use { DataId: ruid } only in .ui / .model JSON or builder patch data. SpriteRUID remains a plain string.
-- World: sprite or animationclip RUID both work
self.Entity.SpriteRendererComponent.SpriteRUID = ruid
-- UI: sprite or animationclip RUID both work
self.Entity.SpriteGUIRendererComponent.ImageRUID = DataRef(ruid)A skeleton / avataritem RUID assigned without the thumbnail:// prefix fails silently (no error, nothing renders).
animationclip: single animation vs multi-state
- Single looping animation (background deco, idle effect, prop): set
SpriteRUID
or ImageRUID directly to the animationclip RUID.
- Multi-state (stand / move / attack / hit / die): use
StateAnimationComponent
\+ ActionSheet. See `msw-general/references/monster.md`.
thumbnail:// prefix — static thumbnail from any resource
Prepend thumbnail:// to SpriteRUID or ImageRUID to render a static thumbnail image from any resource — useful for icons, preview images, and item thumbnails.
thumbnail://<32-char hex RUID>
Accepted types: sprite · animationclip · skeleton · avataritem
-- World thumbnail (any resource type)
self.Entity.SpriteRendererComponent.SpriteRUID = "thumbnail://" .. anyRuid
-- UI thumbnail (any resource type)
self.Entity.SpriteGUIRendererComponent.ImageRUID = DataRef("thumbnail://" .. anyRuid)Primary use case: avataritem icons
avataritem RUIDs cannot render without thumbnail://. With the prefix they become item icons for inventory slots, shop listings, and equip previews.
slotEntity.SpriteGUIRendererComponent.ImageRUID = DataRef("thumbnail://" .. avatarItemRuid)Search avatar item RUIDs with the msw-search skill (searchAvatarItems).
Common pitfalls
skeleton/avataritemdirectly intoSpriteRUID/ImageRUIDwithout prefix → silently invisible.thumbnail://= static image only. For live animation, assign theanimationclipRUID directly (no prefix).- Runtime
.mluausesImageRUID = DataRef("..."); the{ "DataId": "..." }object form is.ui/.modelJSON only (the prefix goes insideDataId, not a separate field). Do not use the table form in runtime code — the LSP rejects it as aDataReftype mismatch. CostumeManagerComponent.Custom*Equip,StateAnimationComponent.ActionSheet, andSkeletonRendererComponent.SkeletonRUIDdo not acceptthumbnail://.- Do not prepend
thumbnail://to a RUID that was already retrieved as a thumbnail or icon image frommsw-search. The prefix converts a source resource into its thumbnail — applying it to an already-thumbnail sprite is logically redundant. If the search query targeted an icon / thumbnail image and returned aspriteRUID, assign that RUID directly without any prefix. - To search for RUIDs use the
msw-searchskill —searchAvatarItemsfor avatar items;searchResourcesfor everything else.

