Load and unload scenes at runtime

Note

Make sure all the scenes you want to load are included in the build as root assets (indicated with blue icons in the Asset View).

To include a scene in the build, in the Asset View, right-click the scene asset and select Include in build as root asset.

For more information about including assets in the build, see .

For more information about scene hierarchies, see Manage scenes.

Xenko also includes a scene streaming script that uses a to load scenes.

Note

To add a scene streaming script, in the Asset View (bottom pane by default), click Add asset and select Scripts > Scene streaming.

Scene streaming script

Game Studio adds a scene streaming script to your project assets.

  • Create a trigger entity. When this is triggered at runtime, Xenko loads the scene. For more information about creating triggers, see Triggers.

    How the entity is triggered is defined in the collider properties. For more information, see .

  • Create an entity and position it where you want the scene to load.

Note

If the scene streaming script doesn't appear in the list of components, reload the assemblies.

Game Studio adds the script to the entity as a component.

Scene streaming properties

  • Under Url, specify the URL of the scene you want to load.

  • Under Trigger, specify the entity you created in step 1.

See also