TypedAssetRef for scene fields in components
Problem
Scene IDs are currently hard-coded as GUID strings in component scripts (see examples/scene-management/assets/SceneDirector.zig). The component-field hydrator does not support a TypedAssetRef(.scene) variant, so designers cannot wire scene transitions from the inspector.
Goal
Extend the asset-ref hydration pipeline so a component can declare a scene field:
pub const MyDirector = struct {
pub const is_component = true;
next_scene: engine.TypedAssetRef(.scene) = .{},
pub fn update(self: *MyDirector, frame: engine.Frame) void {
const mgr = frame.service(engine.SceneManager) orelse return;
if (frame.input.wasKeyPressed(.space))
mgr.requestLoad(self.next_scene.guid(), .single);
}
};and have the inspector show a scene-asset picker for that field, serialised into the scene JSON as a GUID.
Scope
- Add
.scenevariant toTypedAssetRef(or make it generic overAssetType). - Extend the component-field scanner to recognise
TypedAssetRef(.scene)fields. - Add inspector UI: asset-picker button filtered to
.json(scene) assets. - Serialise/deserialise the GUID in scene JSON (already works for material refs — same path).
- Update
SceneDirectorinexamples/scene-management/to use the ref instead of the hard-coded constant.
Context
- Scene management API implemented in issue #22 (closed).
- Material
TypedAssetRefhydration is already in place — this follows the same pattern. - Gap documented in
docs/plans/scene-management.md("Scene references as data").