Scene Management
Scenes are the primary unit of content in SafiEngine. Each scene is a JSON-based .scene file containing serialized entities and their components.
File Menu Operations
On macOS, file dialogs use native osascript panels. On other platforms, scenes default to assets/scenes/default.scene.
Scene Format
Scenes are stored as .scene JSON files in your project's assets/scenes/ directory. The engine serializes and deserializes entities with all their components via Scene::Save() and Scene::Load().
Play Mode
Play mode lets you test your scene with physics, scripts, and audio running live.
Entering Play Mode
When you press Play:
- The editor takes a snapshot of the entire scene (serializes all entities to a JSON string)
- The engine switches to playing state — physics simulates, native scripts execute, audio plays
Exiting Play Mode
When you press Stop:
- The editor restores the scene from the snapshot (deserializes back to the pre-play state)
- The selected entity is cleared
- The script engine is shut down and re-initialized (hot-reload)
- The snapshot is discarded
This means any changes made during play mode (moved objects, spawned entities, etc.) are automatically reverted when you stop.
Unsaved Changes
If you close the editor or open a new scene with unsaved changes, a confirmation dialog appears with three options:
- Save & Close — Save first, then proceed
- Discard & Close — Discard changes and proceed
- Cancel — Stay in the current scene
The editor tracks dirty state via an internal flag that is set whenever the scene is modified.