Skip to content

Scene Manager

Arnis Lielturks edited this page Mar 2, 2019 · 1 revision

Scene loading

Scene manager is responsible for managing the base scene which is available to all Levels and exposed to mods. You can init the scene loading by calling SceneManager::LoadScene() method. This method is automatically called by the Loading level.

Additional Loading steps

While the scene is loading, it is possible to register additional load steps using event system.

Registering load step

AS sample

VariantMap data;
data["Name"] = "Loading step sample"; // Name of the loading step, this will be displayed in the `Loading` level. 
data["Event"] = "LoadStepSample"; // Event name that should be called to start this loading step
SendEvent("RegisterLoadingStep", data); // Register the loading step in the system

Starting load step

AS sample

SubscribeToEvent("LoadStepSample", "HandleLoadStepSample");

void HandleLoadSkills()
{
    VariantMap data;
    data["Event"] = "LoadStepSample";
    // Sent event to let the system know that we will handle this loading step
    // If this event is not sent, loading system will mark this loading step as finished when
    // certain amount of time has passed and no ACK message was received.
    SendEvent("AckLoadingStep", data);

    // Imitate loading
    DelayedExecute(2.0, false, "void FinishLoadStepSample()");
}

void FinishLoadStepSample()
{
    // Let the loading system know that we finished our work
    VariantMap data;
    data["Event"] = "LoadStepSample";
    SendEvent("LoadingStepFinished", data);
}

See example of the full loading step lifetime here: https://github.com/ArnisLielturks/Urho3D-Project-Template/blob/master/bin/Data/Mods/LoadStepImitator.as

Clone this wiki locally