menu_bookDocumentation

ISceneStartup: Host and Client Scene Initialization Events

calendar_today May 20, 2026 schedule ~1 min read person PatrickJr verified 50
ISceneStartup is a scene event interface for listening to scene initialization on host and client. It runs when pressing play in editor, loading a game, or joining a server.

Interface

CSHARP
public interface ISceneStartup : ISceneEvent<ISceneStartup>
{
    void OnHostPreInitialize( SceneFile scene );
    void OnHostInitialize();
    void OnClientInitialize();
}

OnHostPreInitialize

Called before the scene is loaded on the host. The scene is empty — only GameObjectSystem instances receive this since no Components exist yet.

OnHostInitialize

Called after the scene is loaded on the host. All GameObjects and Components are accessible. Good place to spawn shared resources:

CSHARP
public sealed class MyGameManager : GameObjectSystem<MyGameManager>, ISceneStartup
{
    public MyGameManager( Scene scene ) : base( scene ) { }

    void ISceneStartup.OnHostInitialize()
    {
        // Additively load the engine scene (sent to clients on join)
        var slo = new SceneLoadOptions();
        slo.IsAdditive = true;
        slo.SetScene( "scenes/engine.scene" );
        Scene.Load( slo );

        // Start hosting a lobby
        Networking.CreateLobby();
    }
}

OnClientInitialize

Called after scene load on both host and client. NOT called on dedicated servers. Spawn client-side only objects here, but mark them as not networked — otherwise the host will snapshot and send them to joining clients.

"Host" Terminology

"Host" means the computer in charge: the player in singleplayer, a dedicated server, or the lobby host. Basically anyone except a client connected to someone else's server.

Was this helpful?