ezEngine  Release 25.03
ezSceneLoadUtility Class Reference

This class allows to load a scene in the background and switch to it, once loading has finished. More...

#include <SceneLoadUtil.h>

Public Types

enum  LoadingState {
  NotStarted, Ongoing, FinishedSuccessfully, LoadingState::FinishedAndRetrieved,
  Failed
}
 

Public Member Functions

LoadingState GetLoadingState () const
 Returns whether loading is still ongoing or finished.
 
float GetLoadingProgress () const
 Returns a loading progress value in 0 to 1 range.
 
ezStringView GetLoadingFailureReason () const
 In case loading failed, this returns what went wrong.
 
void StartSceneLoading (ezStringView sSceneFile, ezStringView sPreloadCollectionFile)
 Starts loading a scene. If provided, the assets in the collection are loaded first and then the scene is instantiated. More...
 
void TickSceneLoading ()
 This has to be called periodically (usually once per frame) to progress the scene loading. More...
 
ezUniquePtr< ezWorldRetrieveLoadedScene ()
 Once loading is finished successfully, call this to take ownership of the loaded scene. More...
 
ezStringView GetRequestedScene () const
 Returns the path to the scene file as it was originally requested.
 
ezStringView GetRedirectedScene () const
 Returns the path to the scene file after it was redirected.
 

Detailed Description

This class allows to load a scene in the background and switch to it, once loading has finished.

Member Enumeration Documentation

◆ LoadingState

Enumerator
FinishedAndRetrieved 

Loading succeeded and someone already called RetrieveLoadedScene()

Member Function Documentation

◆ RetrieveLoadedScene()

ezUniquePtr< ezWorld > ezSceneLoadUtility::RetrieveLoadedScene ( )

Once loading is finished successfully, call this to take ownership of the loaded scene.

Afterwards there is no point in keeping the ezSceneLoadUtility around anymore and it should be deleted.

◆ StartSceneLoading()

void ezSceneLoadUtility::StartSceneLoading ( ezStringView  sSceneFile,
ezStringView  sPreloadCollectionFile 
)

Starts loading a scene. If provided, the assets in the collection are loaded first and then the scene is instantiated.

Using a collection will make loading in the background much smoother. Without it, most assets will be loaded once the scene gets updated for the first time, resulting in very long delays.

◆ TickSceneLoading()

void ezSceneLoadUtility::TickSceneLoading ( )

This has to be called periodically (usually once per frame) to progress the scene loading.

Call GetLoadingState() afterwards to check whether loading has finished or failed.


The documentation for this class was generated from the following files: