baker-depends-on
Register all data sources a Baker reads via Baker API methods so the baking system reruns the Baker when any of those sources change, enabling correct incremental live-baking.
- License 许可
- MIT
- 最近更新
- 2026-07-25
- Stars
- ★ 8
- Forks
- 0
01 前言 Front Matter
- name
- baker-depends-on
- tags
- [ "baking" ]
- metadata
- { "tier": 3, "internal-only": true }
- description
- Register all data sources a Baker reads via Baker API methods so the baking system reruns the Baker when any of those sources change, enabling correct incremental live-baking.
03 SKILL.md 正文
Baker DependsOn — Dependency Registration
Intent
Register all data sources a Baker reads via Baker API methods so the baking system reruns the Baker when any of those sources change, enabling correct incremental live-baking.
Use When
Any Baker that reads assets, sibling components, referenced GameObjects, ScriptableObjects, or nested asset data beyond the primary authoring MonoBehaviour.
Avoid When
There is no "avoid when" — if you read it, register it. Unregistered reads produce stale baked data that is silent and hard to diagnose.
Senior Pattern
- Use
GetComponent<T>(gameObject)instead ofauthoring.GetComponent<T>()— Baker API method registers the dependency implicitly. - Use
DependsOn(asset)for any asset reference (Mesh, Texture, ScriptableObject, etc.) read in the Baker. - Register DependsOn BEFORE the null check — a null asset may mean "deleted from disk"; the dependency must be registered so the Baker reruns when it is restored.
- Chain DependsOn for nested asset references:
DependsOn(authoring.Info); DependsOn(authoring.Info.Mesh); - Do NOT call
DependsOnin a BakingSystem — not supported and silently ignored.
Code Template
public override void Bake(MeshConfigAuthoring authoring)
{
// Register BEFORE null check
DependsOn(authoring.SourceMesh);
DependsOn(authoring.Config);
if (authoring.Config != null)
DependsOn(authoring.Config.Material); // nested dependency
if (authoring.SourceMesh == null || authoring.Config == null)
return;
// GetComponent registers transform dependency implicitly
var parentTransform = GetComponent<Transform>(authoring.ReferenceGO);
var entity = GetEntity(TransformUsageFlags.None);
AddComponent(entity, new MeshConfig
{
Scale = authoring.Config.Scale,
Offset = parentTransform.localPosition
});
}
Anti-Patterns
- Reading
authoring.transformdirectly instead ofGetComponent<Transform>()— dependency bypassed, Baker won't rerun on transform change. - Calling
DependsOnafter a null-guard early return — if the asset is currently null, the dependency is never registered and won't trigger rebaking when the asset is restored. - Accessing
authoring.someScriptableObject.FieldwithoutDependsOn(authoring.someScriptableObject)— SO changes are invisible to the baking system.
Runtime Risks
No runtime errors — baking dependency failures produce stale baked data. Effects are silent wrong values, missing components, or outdated blobs. Discovered during iteration, not at runtime.
Performance Notes
Dependency tracking is bake-time only. The more precise the dependencies, the faster incremental rebaking (fewer Bakers triggered per asset change).
Architecture Guidance
Think of Baker API methods as the "input declaration" of the Baker. Everything the Baker reads must be declared via the Baker API. Direct C# field access on authoring bypasses the declaration.
Related Skills
[[baker-authoring-conversion]]
04 同仓库更多 Skills
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.
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.
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.
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.
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.
valid_skill
A complete, well-formed test fixture skill for SkillHub validation testing. Covers basic task routing and code review for Unity projects.