AGENT SKILL

baking-type-component

Mark a component as existing only in the baking world so it can carry intermediate data from Bakers to baking systems without appearing in the runtime world.

License 许可
MIT
最近更新
2026-07-25
Stars
★ 8
Forks
0

01 前言 Front Matter

name
baking-type-component
tags
[ "baking" ]
metadata
{ "tier": 3, "internal-only": true }
description
Mark a component as existing only in the baking world so it can carry intermediate data from Bakers to baking systems without appearing in the runtime world.

03 SKILL.md 正文

BakingType Component

Intent

Mark a component as existing only in the baking world so it can carry intermediate data from Bakers to baking systems without appearing in the runtime world.

Use When

A Baker needs to pass data to a baking system (WorldSystemFilterFlags.BakingSystem) that cannot be expressed in the final runtime component. Multi-stage baking pipelines, cross-entity aggregation, blob asset staging.

Avoid When

The data belongs in the runtime world — use a normal IComponentData. Avoid when the data only needs to survive within a single baking pass — use [TemporaryBakingType] instead.

Senior Pattern

  • [BakingType] attribute on IComponentData or IBufferElementData struct.
  • Baker adds the [BakingType] component as a staging area for the baking system to read.
  • Baking system reads the [BakingType] component, computes the final result, and adds the runtime component.
  • [BakingType] is automatically stripped from the destination runtime world after all baking systems complete.
  • Can also be applied to managed class components ([BakingType] public class MeshArrayBakingType : IComponentData).

Code Template

// Staging component — exists only during baking
[BakingType]
public struct RawMeshData : IComponentData
{
    public float MeshScale;
    public Hash128 SourceHash;
}

// Staging buffer — Baker populates, baking system reads
[BakingType]
public struct RawVertex : IBufferElementData
{
    public float3 Position;
}

// Baker stages the data:
class Baker : Baker<MeshAuthoring>
{
    public override void Bake(MeshAuthoring authoring)
    {
        DependsOn(authoring.Mesh);
        var entity = GetEntity(TransformUsageFlags.None);
        AddComponent(entity, new RawMeshData
        {
            MeshScale = authoring.Scale,
            SourceHash = ComputeHash(authoring.Mesh)
        });
        // Baking system will read RawMeshData and produce BlobAssetReference<MeshBlobAsset>
    }
}

Anti-Patterns

  • Forgetting [BakingType] on an intermediate component — it leaks into the runtime world, pollutes archetypes, wastes memory.
  • Reading a [BakingType] component from a runtime system — it doesn't exist, silent no-op or exception.
  • Using [BakingType] when [TemporaryBakingType] would suffice — choose based on whether data must survive across multiple baking system passes.

Runtime Risks

No runtime errors from correct use — wrong use leaks baking data into the runtime world, causing archetype pollution and potential system misfires.

Performance Notes

[BakingType] components exist only during baking. Zero runtime memory or CPU cost. Stripped automatically — no cleanup code required.

Architecture Guidance

Think of [BakingType] as a typed message channel from Baker to baking system. Baker writes the staging data; baking system reads, transforms, and produces the runtime component. This split keeps Bakers simple and baking systems reusable.

Related Skills

[[baker-authoring-conversion]], [[baking-system]]

04 同仓库更多 Skills

dyCuong03
dyCuong03/unity-agent-team

dots-update-groups

How to choose the right ECS system group and ordering so per-frame and per-fixed-step work is deterministic and never races its own readers. Covers InitializationSystemGroup / SimulationSystemGroup / PresentationSystemGroup / FixedStepSimulationSystemGroup / VariableRateSimulationSystemGroup, UpdateBefore / UpdateAfter peer ordering, OrderFirst / OrderLast group-boundary placement, RateManager, and the cross-group ordering trap. Use when adding an ISystem, fixing "value visible one frame late" bugs, or coupling simulation to a fixed timestep.

★ 8
dyCuong03
dyCuong03/unity-agent-team

dots-transform-patterns

The Entities 1.x transform model — LocalTransform (writable input) vs LocalToWorld (system-owned matrix), Parent/Child hierarchy, reparenting cost, uniform vs non-uniform scale (PostTransformMatrix), and when to opt out with custom transform systems. Use when designing parent/child hierarchies, runtime reparenting (mount/dismount/socket), or choosing transform components at the Baker boundary.

★ 8
dyCuong03
dyCuong03/unity-agent-team

dots-singleton-patterns

Model cross-system shared configuration and game state as a single-entity component with a strict single-writer contract. Covers RequireForUpdate gating, SystemAPI.GetSingleton / GetSingletonRW / HasSingleton / TryGetSingleton, bake-time vs runtime-created vs ECB-system singletons, the "exactly one entity" runtime invariant, and the single-writer rule. Use when designing frame-stable global config, shared mutable state, or any component intended to exist on exactly one entity.

律师与法务
★ 8
dyCuong03
dyCuong03/unity-agent-team

dots-hybrid-bridge

The one-way bridge between DOTS-owned runtime state and Unity-owned presentation. Covers UnityObjectRef for managed asset refs in components, the DOTS-writes / Unity-reads ownership rule, when to use managed IComponentData vs UnityObjectRef vs CompanionComponent, baker-bridge vs runtime-bridge, and SubScene boundary rules. Use when an entity must reference Unity assets (Mesh, Material, AudioClip, ScriptableObject), a MonoBehaviour view must read entity state, or input/UI must trigger ECS work.

★ 8
dyCuong03
dyCuong03/unity-agent-team

dots-event-driven-ecs

Model one-frame events and external requests in ECS without dual ownership, polling, or persistent state leaks. Covers request-tag pattern with ECB, enableable command components (no structural change), event buffers (IBufferElementData), explicit consumer ownership, one-frame latency rules, and the banned C# event / UnityEvent / static bus anti-patterns. Use when input/UI/network must trigger ECS work, when a one-frame signal fans out to N consumers (damage, hit, collision), or when state changes must be processed exactly once.

★ 8
dyCuong03
dyCuong03/unity-agent-team

valid_skill

A complete, well-formed test fixture skill for SkillHub validation testing. Covers basic task routing and code review for Unity projects.

代码审查测试与质量
★ 8