Skip to main content

process_pending_save_as_material

Function process_pending_save_as_material 

Source
pub fn process_pending_save_as_material(
    project_vfs: Option<&Arc<Mutex<ProjectVfs>>>,
    world: &mut GameWorld,
    editor_state: &Arc<Mutex<EditorState>>,
)
Expand description

Drains [EditorState::pending_save_as_material]: serializes the entity’s inline material to a .kmat (RON), writes it under assets/materials/<name>.kmat, reindexes the VFS, then rewrites the entity’s component to MaterialRef::Asset(uuid) so it references the freshly-saved shared, reloadable asset.

The .kmat bytes are exactly what the material decoder expects: material_to_json(&dyn Material) (the { type_name, material } value split) RON-encoded. No project open → logged warning, no-op.