menu_bookDocumentation
Scene Metadata: ISceneMetadata for Queryable Scene and Prefab Data
The ISceneMetadata interface in s&box allows Components to save data that can be accessed without loading a Scene or cloning a Prefab. Metadata is accessible via SceneFile or PrefabFile directly.
Implementing ISceneMetadata
CSHARP
public class MySceneInfo : Component, ISceneMetadata
{
[Property] public string Title { get; set; }
[Property] public string Group { get; set; }
[Property, TextArea] public string Description { get; set; }
[Property] public int Difficulty { get; set; } = 1;
public Dictionary<string, string> GetMetadata()
{
return new Dictionary<string, string>
{
{ "Title", Title },
{ "Group", Group },
{ "Description", Description },
{ "Difficulty", Difficulty.ToString() }
};
}
}Reading Scene Metadata
Call GetMetadata(key, fallback) on any SceneFile:CSHARP
var title = sceneFile.GetMetadata( "Title", "Untitled" );Reading Prefab Metadata
Works identically — useful for spawning enemies by difficulty/weight:CSHARP
var allEnemies = ResourceLibrary.GetAll<PrefabFile>()
.Where( x => int.Parse( x.GetMetadata( "Difficulty", "0" ) ) <= difficulty );This enables data-driven systems where scenes and prefabs carry queryable metadata without needing to load them.
Was this helpful?