MassBattleAgentCreatorState
Source/MassBattleEditor/Public/AgentCreator/MassBattleAgentCreatorState.h
概述Overview
这是 Agent Creator 面板挂进下方详情视图的那个对象。它一次承载本次编辑的全部输入与产出:这次要烘哪几份单位配置、输出资产名与生成路径、渲染带表、三种渲染族的源资产引用,以及烘焙产出的资产引用。字段按源码分四个分类显示(0.RenderProfile / 1.RenderBands / 2.RenderSources / 3.GeneratedAssets),标了 EditAnywhere 的字段都能在面板里直接改,不需要写代码。
This is the object the Agent Creator panel shows in its embedded details view. It carries everything for the current editing session in one place: which unit configs this bake targets, the output asset name and generate path, the render band table, the per-family source asset references, and the references to baked outputs. Its fields are grouped exactly as in the source (0.RenderProfile / 1.RenderBands / 2.RenderSources / 3.GeneratedAssets), and every field marked EditAnywhere is editable right there in the panel — no code required.
这个对象是面板里的临时状态,本身不是可保存的资产:关闭面板后它不会作为资产留下,面板里改过的值也不会自行存盘。让一套设置跨会话活下来的是单位配置里的烘焙配方——每次生成成功后,这份设置都会写进清单里每一份配置;面板上的 Save Recipe 同样会写,Load Recipe 则从主配置读回。生成出来的资产是磁盘上的真实资产,不受面板开关影响。
This object is transient panel state, not a saveable asset: it does not survive the panel as an asset, and edited values are not persisted on their own. What keeps a setup across sessions is the bake recipe stored inside the unit configs — after every successful generate the setup is written into every listed config; the panel's Save Recipe writes it too, and Load Recipe reads it back from the primary config. Generated assets are unaffected: those are real assets on disk.
继承Inheritance
直接派生自 UObject,对外没有方法和事件。所有烘焙行为都在面板与 Creator 核心里,字段只是它们读写的数据。
Derives directly from UObject with no public methods or events. All behaviour lives in the panel and the creator core; these fields are simply the data they read and write.
0.RenderProfile Category
这一组回答「这次烘谁、产物叫什么、写到哪」。核心是单位配置清单:第一个非空条目是主配置,Load Recipe 从它取回设置;生成时这份设置连同全部动画/配置字段会写进清单里的每一份配置,所以共用同一套美术资产的几份配置可以用一次重烘一起更新。清单里一份配置都没有时,生成会在 生成路径 / 资产名 下自建一份,并把配方写进去。详情视图始终保留一行,删掉最后一行也会补回来。贴图与动画的递归搜索路径不单独成行,但它同样是配方的一部分。
This category answers "which units this bake targets, what the outputs are called, and where they go". At its centre is the unit config list: the first non-null entry is the primary from which Load Recipe restores, and generate writes the setup plus every animation/config field into every listed config — so several configs sharing one set of art assets are updated together by one re-bake. With no config listed at all, generate creates one under generate path / asset name and records the recipe into it. The details view always keeps one row, and removing the last row restores it. The recursive texture/anim search path is not a row of its own, but it is part of the recipe too.
| 名称Name | 类型Type | 默认值 | 说明Description |
|---|---|---|---|
AgentConfigDataAssets | TArray<TObjectPtr<UMassBattleAgentConfigDataAsset>> | 空清单empty | 本配方烘焙的单位配置清单。第一个非空条目是主配置,Load Recipe 从它取回设置;生成把配方与全部动画/配置字段写进清单里的每一份,这些字段因此在多份配置间保持同步。配方只还原 Creator 的设置(资产名、搜索与生成路径、工具模式——只留一个 Advanced 旗标、带表、模型源、图集源、actor 类);网格烘焙输入住在模型源资产上、sprite 帧率住在精灵图集资产上,两者既不保存也不还原。清单为空则生成自建一份。The unit configs this recipe bakes. The first non-null entry is the primary, whose stored recipe Load Recipe restores; generate writes the recipe and every animation/config field into every listed config, so those fields stay in step across several configs. The recipe restores the creator's setup only (asset name, search and generate paths, tool mode as a single Advanced flag, band table, model source, atlas source, actor class); mesh bake inputs live on the model source asset and sprite FPS on the atlas asset, and neither is stored or restored. An empty list lets generate create one. |
AssetName | FString | 空empty | 每个生成资产的名字都从它派生(SM_ / MI_ / VAT_ / NS_ / Renderer_ / AgentConfig_ 等),烘焙用的就是这个名称;它也随配方保存与还原。Asset name every generated asset derives from (SM_ / MI_ / VAT_ / NS_ / Renderer_ / AgentConfig_ and the rest). This is the name the bake uses, and it is part of the saved recipe. |
GeneratePath | FString | 空empty | 每个生成资产写到的输出目录,默认 <源目录>/Gen_<名>;烘焙用的就是这个路径,它也随配方保存与还原。Output folder every generated asset is written under, defaulting to <source dir>/Gen_<name>. This is the path the bake uses, and it is part of the saved recipe. |
工具模式Tool Mode
ToolMode 决定整次烘焙走 Standard 还是 Advanced,并参与字段显隐。它不是用户选项,也不在详情视图里显示:面板按模型源推导——模型源上只带 Assembly 模板的走 Advanced,骨骼网格(或没有源)走 Standard。它没有可编辑的设置面;配方里只留一个 Advanced 旗标,载入之后仍按模型源再推导一次。
ToolMode selects which bake branch runs — Standard or Advanced — and takes part in field visibility. It is not a user choice and is not shown in the details view: the panel derives it from the model source — a model source carrying only an Assembly template selects Advanced, a skeletal mesh (or no source) selects Standard. It has no editable setting of its own; the recipe keeps only an Advanced flag, and after loading it is derived from the model source again.
| 值Value | 显示名Display | 说明Description |
|---|---|---|
Standard | Standard | 单单位快速路径:一份骨骼网格、一张图集或一个 actor 类,逐带选择渲染模式。Single-unit quick path: one skeletal mesh, one atlas or one actor class, with a render mode chosen per band. |
Advanced | Advanced | Assembly 模板复合:由模板驱动的多部件 × 多版本渲染结构。Assembly template composite: a template-driven multi-part × multi-version render structure. |
两种分支读的是同一张带表:Standard 烘一份单网格或一张图集,Advanced 按带把整具装配烘出来。
Both branches read the same band table: Standard bakes a single mesh or a single atlas, Advanced bakes the whole assembly band by band.
1.RenderBands Category
渲染带表:1–5 条按屏幕尺寸切的管线切片,每条路由到一种渲染模式,外加 VatVert 的几何 LOD 下限。带是屏幕尺寸分层,不是网格 LOD 行——运行时由 Niagara 系统决定画哪一级几何 LOD,带表只管什么距离用哪种表现。多数单位只有一条带;五条是上限,因为运行时 LOD 表正好五个槽。
The render band table: 1–5 screen-size pipeline slices, each routing to one render mode, plus the VatVert geometry-LOD floor. A band is a screen-size tier, not a mesh-LOD row — at runtime the Niagara system picks which geometry level to draw, and the band table only decides which representation applies at which distance. Most units need a single band; five is the ceiling because the runtime LOD table has exactly five slots.
| 名称Name | 类型Type | 默认值 | 说明Description |
|---|---|---|---|
Bands | TArray<FLODDataEd>(1–5 条)(1–5 entries) | 空(新建时置为一条 ScreenSize 0 的 Bone CS 带) | 逐带一行:屏幕尺寸是本带的下界——投影占屏大于等于它时启用本带,最后一条应为 0;渲染模式取 Actor / Bone CS / VAT Vertex / Sprite / None,一档一种。None 什么都不画;网格档需要模型源里的骨骼网格;Sprite 档需要精灵图集资产;Actor 档按配置上的 actor 类生成 actor、不画网格。带在表中的位置就是运行时槽位,位置本身不可编辑。One row per band: the screen size is that band's lower bound — the band applies when the projected screen size is at or above it, and the last band should be 0. The render mode is Actor / Bone CS / VAT Vertex / Sprite / None, one per band. None draws nothing; mesh bands need the skeletal mesh from the model source; Sprite bands need the sprite atlas asset; Actor bands spawn that band's actor from the config's actor class instead of drawing a mesh. A band's position in the table is its runtime slot, and the position itself is not editable. |
VatVertLODMin | int32 | 0 | VatVert 烘焙的第一级几何 LOD(0 = LOD0):烘焙从这一级一直覆盖到网格的最后一级几何 LOD。没有任何档路由到 VatVert 时,这个设置不生效。First geometry LOD baked for VatVert (0 = LOD0): the bake covers it through the mesh's last geometry level. Ignored while no band routes to VatVert. |
2.RenderSources Category
三个源槽,每个只为一种渲染族存在:有 Actor 档才出现 actor 类,有网格档(Bone CS / VAT Vertex)才需要模型源,有 Sprite 档才需要精灵图集资产。源本身放在数据资产里——模型源在 ATT、图集在 ATA——这里只记引用。Advanced 即使没有网格档也保留模型源行,因为它的动画列表来自这份资产的八个桶。
Three source slots, each existing only because some band routes to that render family: Actor bands ask for the actor class, mesh bands (Bone CS / VAT Vertex) need the model source, Sprite bands need the sprite atlas asset. The sources themselves live on data assets — model source on the ATT, atlas on the ATA — and this state only holds the reference. Advanced keeps the model-source row visible even without mesh bands, because its clip list comes from that asset's eight buckets.
| 名称Name | 类型Type | 默认值 | 说明Description |
|---|---|---|---|
ActorClass | TSubclassOf<AActor> | nullptr | Actor 档生成的 actor 类(软类引用,写进单位配置);直接选定义它的蓝图,不是在类名下拉里挑。只有存在 Actor 档时出现。Actor class spawned for Actor bands (soft class ref written to the agent config); pick the Blueprint that defines it rather than a class name in a combo. Shown only while an Actor band exists. |
MeshAsset | TObjectPtr<UMassBattleATTDataAsset> | nullptr | 模型源资产(在 Mesh Prep 里填写):骨骼网格 + 八个动画桶 + 材质槽,或一份 Assembly 模板——二选一。有网格档时出现;Advanced 始终保留该行,动画列表仍取自这份资产的八个桶。Model source asset (authored in Mesh Prep): a skeletal mesh plus eight clip buckets and material slots, or one Assembly template — exactly one of the two. Shown for mesh bands; Advanced keeps the row visible because its clip list still comes from this asset's eight buckets. |
SpriteAsset | TObjectPtr<UMassBattleATADataAsset> | nullptr | 精灵图集资产:纹理 + 切分它的网格 + 逐桶帧区间。创建方法:内容浏览器右键 → 杂项 → 数据资产 → MassBattleATADataAsset(或由 sprite 预填面板产出)。只有存在 Sprite 档时出现。Sprite atlas asset: the texture plus the grid and per-bucket frame ranges it was cut with. Create one via Content Browser → Miscellaneous → Data Asset → MassBattleATADataAsset (or let the sprite prep panel produce it). Shown only while a Sprite band exists. |
动画数据在哪里Where Anim Clips Live
这份状态里没有可编辑的动画行。网格族的动画是模型源资产(ATT)上的八个动画桶;sprite 族的帧与变体在精灵图集资产(ATA)上。要换动画就换源资产,烘焙从源资产读;配方只记录源资产的引用,不记录动画内容。
There are no editable animation rows in this state. Mesh-family clips are the eight buckets on the model source asset (ATT); sprite frames and variants live on the sprite atlas asset (ATA). To change animations, change the source asset — the bake reads from it. The recipe records only the source asset reference, not clip content.
图集参数在哪里Where Atlas Parameters Live
图集的网格布局与逐桶帧区间也不在这份状态里:它们跟着精灵图集资产(ATA)走——纹理、切分它的网格以及逐桶帧区间都在那份资产上。帧率同样存在 ATA 上,不写进配方。所以改图集布局要在 ATA 上改,Creator 只引用它,并在生成时产出图集材质实例。
The atlas grid and per-bucket frame ranges are not on this state either: they travel with the sprite atlas asset (ATA) — the texture, the grid it was cut with and the per-bucket frame ranges all live on that asset. The sprite FPS lives on the ATA as well and is not part of the recipe. So change the atlas layout on the ATA; the creator only references it and produces the atlas material instance at generate time.
3.GeneratedAssets Category
这些是产出槽,不是输入。它们记录烘焙产出的资产引用:正常流程里不手填,让生成去写。重新烘焙到同一目录时会优先复用同名资产并原位覆盖,名字不变、既有引用不漂移。这一组不参与撤销——Ctrl+Z 会还原作者填的字段,而这几行保持在烘焙后的值。
These are output slots, not inputs. They hold references to what the bake produced; in the normal flow you never fill them by hand — generate writes them. On a re-bake into the same folder, same-named assets are reused and overwritten in place, so names stay stable and existing references do not drift. This group takes no part in undo — Ctrl+Z restores authored fields, while these rows stay at their post-bake values.
| 名称Name | 类型Type | 默认值 | 说明Description |
|---|---|---|---|
BakedStaticMeshes | TArray<TObjectPtr<UStaticMesh>> | 空empty | 上次烘焙产出的全部静态网格,按烘焙顺序:单网格路径一个,复合烘焙按每个部件 / 版本各一个。下标 0 是主网格——渲染器默认值、材质收集、单位配置这些单网格步骤都以它为准。只有存在网格档时出现。Every static mesh the bake produced, in bake order: one for the single-mesh path, one per part/version for the composite. Index 0 is the primary mesh that the single-mesh steps (renderer defaults, material collection, agent config) work from. Shown only while a mesh band exists. |
NSAsset | TObjectPtr<UNiagaraSystem> | nullptr | 复制出的 Niagara 系统。模板来自烘焙模板设置(编辑器偏好 → 插件 → MassBattle → 烘焙模板),取不到时回落到插件自带的默认配置与内置模板路径。The duplicated Niagara system. Its template comes from the bake template setting (Editor Preferences → Plugins → MassBattle → Bake Templates), falling back to the plugin's own default config and the built-in template paths. |
RendererInstance | TSubclassOf<AMassBattleAgentRenderer> | nullptr | 复制出的渲染器蓝图类,模板与 Niagara 系统同源(烘焙模板设置,取不到时逐级回落)。The duplicated renderer Blueprint class; its template comes from the same place as the Niagara system (the bake template setting, with the same layered fallback). |
VATTextures | TArray<FVATTexArray> | 空empty | 创建的 VAT 纹理。下标 0 恒为动画数据纹理(骨骼与顶点模式通用),其后的每一项对应一级 LOD 的烘焙 VAT 纹理。只有存在网格档时出现。Created VAT textures. Index 0 is always the animation-data texture (shared by bone and vertex mode); each following entry holds the baked VAT textures of one LOD. Shown only while a mesh band exists. |
SpriteMaterialInstance | TObjectPtr<UMaterialInterface> | nullptr | 生成的图集材质实例,写入图集参数。只有存在 Sprite 档时出现。The generated atlas material instance, which receives the atlas parameters. Shown only while a Sprite band exists. |
字段显隐Fields per Band Family
显隐由带表里的渲染族决定:源槽只在存在对应族时出现,网格与 sprite 产物同理。唯一的例外是模型源行——Advanced 下它始终出现,即使没有网格档。隐藏只是不把行画出来,字段里已有的值仍在,切回对应族即可继续用。
Visibility follows the render families in the band table: a source slot appears only while its family exists, and the mesh / sprite outputs follow the same rule. The one exception is the model-source row — under Advanced it stays visible even with no mesh bands. Hiding only stops the row from being drawn; existing values are kept, so switching back lets you keep using them.
| 字段Field | 出现条件When Shown |
|---|---|
AgentConfigDataAssets、AssetName、GeneratePath、LODSettings、NSAsset、RendererInstance | 始终显示Always |
MeshAsset | 有网格档(Bone CS / VAT Vertex),或 AdvancedA mesh band (Bone CS / VAT Vertex) exists, or Advanced |
ActorClass | 有 Actor 档An Actor band exists |
SpriteAsset、SpriteMaterialInstance | 有 Sprite 档A Sprite band exists |
BakedStaticMeshes、VATTextures | 有网格档A mesh band exists |
补充说明Notes
① 配置清单默认为空,也允许一直留空:删到零行就停在零行,生成时按需在生成路径下自建一份配置并填进清单。
① The config list starts empty and may stay empty: deleting the last row leaves the list at zero, and generate creates a config under the generate path on demand and places it into the list.
② 名称与路径会在执行前被净化:非法字符被替换;AssetName 或 GeneratePath 为空、或路径不是合法内容路径时,生成只记录一条错误就返回,不会写出半成品。
② Names and paths are sanitised before execution: illegal characters are replaced, and if AssetName or GeneratePath is empty — or the path is not a valid content path — generate logs one error and returns without writing anything half-finished.
③ 重复烘焙同一个输出目录时,生成会先弹一个确认框,按类别列出已存在的生成资产;取消则磁盘上什么都不动,确认才原位覆盖并沿用原来的资产名。
③ When re-baking into the same output folder, generate first asks for confirmation and lists the existing generated assets by category; cancelling leaves everything on disk untouched, confirming overwrites in place and keeps the original asset names.
④ 详情视图关闭了搜索栏:字段集固定且分类清晰,过滤框只会增加噪音。字段较多时按分类折叠即可。
④ The details view has no search bar on purpose: the field set is fixed and clearly categorised, so a filter box would only add noise. With this many fields, collapse by category instead.