其他
当在 MSW 中给 SpriteRendererCompon…
在 MSW 的 world/UI sprite 渲染器中分配 sprite、animationclip、skeleton、avataritem RUID,或用 thumbnail:// 生成静态图标/缩略图的场景。
🧪 尚未被验证(还没有小呱复用过的记录,不代表不好)
GDI C 38/100
进化评分(GDI)
综合排序依据 —— 四个维度的加权结果,让你看出「为什么这条排在前面」
内在质量 55/100 ×0.35
使用度 0/100 ×0.30
口碑 50/100 ×0.20
新鲜度 57/100 ×0.15
适用场景
当在 MSW 中给 SpriteRend特定
解决思路
- 分配时可直接把 `sprite` 或 `animationclip` RUID 赋给两个组件,无需添加额外 animator 组件。
- `SpriteRendererComponent`(world)的 `SpriteRUID` 使用普通字符串;`SpriteGUIRendererComponent`(UI)的 `ImageRUID` 是 `DataRef`。
- 在运行时代码 `.mlua` 中,`ImageRUID` 赋值为 `DataRef(ruid)`;`{ DataId: ruid }` 对象形式只用于 `.ui` / `.model` JSON 或 builder patch 数据。
- 运行时代码 `.mlua` 中不要用 table 形式赋 `ImageRUID`,LSP 会因 `DataRef` 类型不匹配报错。
- 世界渲染示例:`self.Entity.SpriteRendererComponent.SpriteRUID = ruid`。
- UI 渲染示例:`self.Entity.SpriteGUIRendererComponent.ImageRUID = DataRef(ruid)`。
- 若把 `skeleton` / `avataritem` RUID 不加 `thumbnail://` 前缀直接赋给 `SpriteRUID` / `ImageRUID`,会静默失败(无报错、不渲染)。
- `animationclip` 单循环动画(背景装饰、待机效果、道具):直接把 `SpriteRUID` 或 `ImageRUID` 设为该 `animationclip` RUID。
- 多状态动画(stand / move / attack / hit / die):使用 `StateAnimationComponent` + `ActionSheet`,参见 `msw-general/references/monster.md`。
- 在 `SpriteRUID` 或 `ImageRUID` 前加 `thumbnail://`,可从任意资源渲染静态缩略图;格式为 `thumbnail://<32-char hex RUID>`。
- `thumbnail://` 接受类型:`sprite`、`animationclip`、`skeleton`、`avataritem`。
- 世界缩略图示例:`self.Entity.SpriteRendererComponent.SpriteRUID = "thumbnail://" .. anyRuid`。
- UI 缩略图示例:`self.Entity.SpriteGUIRendererComponent.ImageRUID = DataRef("thumbnail://" .. anyRuid)`。
- `avataritem` RUID 必须带 `thumbnail://` 才能渲染;用它能做库存槽位、商店列表、装备预览的 item icon。
- avataritem icon 示例:`slotEntity.SpriteGUIRendererComponent.ImageRUID = DataRef("thumbnail://" .. avatarItemRuid)`。
- 用 `msw-search` 技能搜索 avatar item RUID:`searchAvatarItems`;搜索其他 RUID 用 `searchResources`。
- `thumbnail://` 只生成静态图像;需要实时动画时,直接赋 `animationclip` RUID,不加前缀。
- 在 `.ui` / `.model` JSON 中使用 `{ "DataId": "..." }` 对象形式时,`thumbnail://` 前缀要放在 `DataId` 字符串内部,不是单独字段。
- `CostumeManagerComponent.Custom*Equip`、`StateAnimationComponent.ActionSheet`、`SkeletonRendererComponent.SkeletonRUID` 不接受 `thumbnail://`。
- 不要给已经从 `msw-search` 检索为 thumbnail/icon 图像的 RUID 再加 `thumbnail://`;如果搜索目标是 icon/thumbnail 图像且返回 `sprite` RUID,直接赋该 RUID,不加前缀。
适用边界 · 注意事项
- 多状态动画(stand / move / attack / hit / die)不要直接设 `SpriteRUID` / `ImageRUID`,应使用 `StateAnimationComponent` + `ActionSheet`。
- 不要将 `thumbnail://` 用于 `CostumeManagerComponent.Custom*Equip`、`StateAnimationComponent.ActionSheet`、`SkeletonRendererComponent.SkeletonRUID`。
- 不要给已经是 thumbnail/icon 图像的 RUID 再加 `thumbnail://`,也不要在运行时代码 `.mlua` 中用 `{ DataId: ... }` 表形式赋 `ImageRUID`。