跳到主要内容

2D 精灵生成

生成 2D 精灵(Sprite)资产:游戏图标、道具图片、角色头像、技能图标、UI 元素等。输出 PNG 自动导入为 Sprite(Texture2D),默认保存到 Assets/TJGenerators/History/

开始

从GUI开始

菜单:AI > 生成 > 生成精灵,或参考 生成3D模型 的开始部分。

从CLI开始

使用 generate_sprite 工具生成精灵。生成完成后,精灵自动保存到项目并可在场景中使用。

输入模式:

模式参数说明
文生精灵prompt纯文字描述
图生精灵image_path(可加 prompt参考图 + 文字指导

至少提供 promptimage_path 之一。


常用模型

精灵生成提供 3 种模型,通过 generator_id 选择:

Frontier Game Design(默认模型)

  • generator_id: frontier-game-design(默认)
  • 适用场景: 游戏图标、道具图、概念向游戏素材,自带游戏化提示词模板
  • 关键参数:
    • prompt:精灵描述
    • image_path:参考图路径
    • imageSizesquare_hd(默认)/ square / portrait_4_3 / portrait_16_9 / landscape_4_3 / landscape_16_9
    • outputFormatpng(默认)/ jpeg
  • 使用本模型时不支持 type_id / style_id,请用描述性 prompt 引导。

火山 SeeDream

  • generator_id: huoshan_seedream(用户说"用火山模型"/"用SeeDream"时切换)
  • 适用场景: 通用精灵生成,支持内容类型/美术风格/背景分割
  • 关键参数:
    • prompt:精灵描述
    • image_path:参考图路径
    • type_id:内容类型 ID(31 种,见下)
    • style_id:美术风格 ID(29 种,见下)
    • size:输出尺寸(默认 2048x2048,8 种预设)
    • is_segmentation:是否自动去除背景(默认 true)
    • q_value:抠图后压缩质量 1–100(默认 75)
    • resize_width:输出最大宽度(px),0 = 不缩放

Frontier(风格化特效)

  • generator_id: frontier-effect
  • 适用场景: 风格化、艺术化特效精灵
  • 关键参数:
    • prompt / image_path
    • resolution0.5K / 1K(默认)/ 2K / 4K
    • aspect_ratioauto(默认)/ 16:9 / 9:16 / 1:1
    • output_formatpng(默认)/ jpeg

内容类型 ID(type_id,仅 SeeDream)

武器(weapon_melee/weapon_ranged/weapon_magic)、护甲与饰品(armor_head/armor_body/armor_shield/armor_accessory)、消耗品(consumable_hp/consumable_mp/consumable_buff)、材料(material_common/material_rare/material_epic)、特殊(key_item/quest_item)、工具(tool_gathering/tool_crafting)、角色(mount/pet/character_hero/character_npc/monster)、场景(furniture/decoration)、UI(ui_button/ui_icon/ui_frame)、技能(skill_active/skill_passive)、效果(effect_buff/effect_debuff)。

美术风格 ID(style_id,仅 SeeDream)

像素类(pixel/pixel_8bit/pixel_16bit)、卡通动漫(cartoon/anime/chibi)、写实(realistic/semi_realistic)、设计风(flat/vector/minimalist)、绘画风(watercolor/oil_painting/sketch/lineart/hand_drawn)、cell_shadinglow_poly、视角(isometric/top_down/side_scroller)、题材(cyberpunk/steampunk/fantasy/sci_fi/horror/cute/gothic/medieval)。

输出尺寸(size,仅 SeeDream)

2048x2048(默认,1:1)、2304x1728(4:3)、1728x2304(3:4)、2560x1440(16:9)、1440x2560(9:16)、2496x1664(3:2)、1664x2496(2:3)、3024x1296(21:9)。


优化

模型与参数组合

  • 默认 Frontier Game Design 适合游戏图标/道具,无需选内容类型与风格,直接用描述性 prompt
  • SeeDream 想精确控制时:组合 type_id + style_id 比纯文字更能引导方向
  • 具体描述道具特征"a glowing blue crystal sword with intricate rune engravings" > "a sword"

尺寸与精度(SeeDream)

  • 最小尺寸约 1920×1920(约 3,686,400 像素),低于此会返回 400 错误
  • 常用 2048x2048,平衡质量与文件体积
  • 需要自动背景去除时启用 is_segmentation: true

精灵缩放

  • 默认 2048px / 100 PPU 的缩放比例 ≈ 20.48 单位宽
  • 放入场景时必须显式设置 localScale0.05f ≈ 1 单位宽,0.10f ≈ 2 单位宽
  • 不设置缩放会导致精灵在场景中异常巨大

并行生成

  • 最大 5 个并发任务,可同时提交多个精灵生成请求

注意事项

  • ⚠️ 默认模型是 Frontier Game Designtype_id / style_id / size / is_segmentation 等参数仅 SeeDream(huoshan_seedream)有效
  • ⚠️ 至少需要 promptimage_path 之一
  • ⚠️ SeeDream 最小尺寸约 1920×1920,请求更小尺寸可能触发 400 错误
  • ⚠️ 精灵默认缩放异常巨大(2048px/100PPU ≈ 20.48 单位),必须设置 localScale
  • ⚠️ 生成耗时 60–180 秒
  • ⚠️ Sprite 与 Image 的区别:Sprite 用于游戏内 2D 素材(透明背景、图标、头像),Image 用于概念图、背景图等非精灵用途
  • ⚠️ 输出路径:默认 Assets/TJGenerators/History/
  • ⚠️ Domain Reload:生成期间不要在磁盘写入 .cs 文件,使用 execute_csharp_script 代替