> For the complete documentation index, see [llms.txt](https://dante-3.gitbook.io/dante-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://dante-3.gitbook.io/dante-docs/modular-experience-system/modular-loading-screen.md).

# Modular Loading Screen

How the ModularLoadingScreen and ModularStartupLoadingScreen modules work.

## Origin

These two modules are sourced from **Epic Games' Lyra project's `CommonLoadingScreen` module**. The core code is unchanged — it was only moved into the MES plugin and class names were updated. You can refer to the corresponding module in Lyra to review the original implementation.

## IModularLoadingProcessInterface

The interface that controls whether the loading screen should be shown.

```cpp
UINTERFACE(MinimalAPI, BlueprintType)
class UModularLoadingProcessInterface : public UInterface

class IModularLoadingProcessInterface
{
    virtual bool ShouldShowLoadingScreen(FString& OutReason) const { return false; }
};
```

Any UObject can implement this interface. The manager queries all registered processors every frame — the loading screen remains visible as long as **any one** of them returns `true`.

### Static Helper

```cpp
static bool ShouldShowLoadingScreen(UObject* TestObject, FString& OutReason);
```

Checks whether an object implements this interface and returns the result.

## UModularLoadingScreenManager

A **GameInstance Subsystem** that manages the display of the loading screen.

```cpp
UCLASS(MinimalAPI)
class UModularLoadingScreenManager : public UGameInstanceSubsystem, public FTickableGameObject
```

### How Does It Work?

1. **Ticks every frame** — `UpdateLoadingScreen()` is called
2. All registered `IModularLoadingProcessInterface` processors are queried
3. Map load state is checked (`PreLoadMap` / `PostLoadMap`)
4. The loading screen is shown or hidden based on the results

### Key Methods

| Method                                            | Description                                  |
| ------------------------------------------------- | -------------------------------------------- |
| `RegisterLoadingProcessor()`                      | Registers a new processor                    |
| `UnregisterLoadingProcessor()`                    | Unregisters a processor                      |
| `GetLoadingScreenDisplayStatus()`                 | Whether it is currently visible              |
| `GetDebugReasonForShowingOrHidingLoadingScreen()` | Why it is being shown/hidden (for debugging) |

### Delegate

```cpp
DECLARE_MULTICAST_DELEGATE_OneParam(FOnLoadingScreenVisibilityChangedDelegate, bool);
FOnLoadingScreenVisibilityChangedDelegate& OnLoadingScreenVisibilityChangedDelegate();
```

Fires when the loading screen is shown or hidden.

### Internal Behavior

* `HandlePreLoadMap()` — Shows the loading screen when map loading begins
* `HandlePostLoadMap()` — When map loading ends (but processors can still block dismissal)
* `ShowLoadingScreen()` — Adds the widget to the viewport, blocks input
* `HideLoadingScreen()` — Removes the widget, releases input
* `ChangePerformanceSettings()` — Adjusts performance settings while the loading screen is displayed

## UModularLoadingProcessTask

A lightweight task class used to create standalone loading states.

If you want to keep the loading screen displayed for the duration of an operation:

```cpp
// Task oluştur — loading screen gösterilmeye başlar
UModularLoadingProcessTask* Task = UModularLoadingProcessTask::CreateTask(WorldContext, TEXT("Loading assets..."));

// ... asenkron işlem yap ...

// Task'ı tamamla — loading screen artık bu task yüzünden gösterilmez
Task->SetComplete();
```

## ModularStartupLoadingScreen

A **pre-load screen** shown during the engine startup phase (before the asset manager is ready).

### Module Structure

| Class                                | Description                                                                      |
| ------------------------------------ | -------------------------------------------------------------------------------- |
| `FModularStartupLoadingScreenModule` | `IModuleInterface` — registers with `FPreLoadScreenManager` in `StartupModule()` |
| `FModularPreLoadScreen`              | `FPreLoadScreenBase` — type `EPreLoadScreenTypes::EngineLoadingScreen`           |
| `SModularPreLoadingScreenWidget`     | Slate widget — a simple black `SBorder`                                          |

### How It Works

1. `StartupModule()` — `FModularPreLoadScreen` is created and `Init()` is called
2. `Init()` — `SModularPreLoadingScreenWidget` is created outside the editor in a renderable environment
3. Registers via `FPreLoadScreenManager::RegisterPreLoadScreen()`
4. Cleaned up via the `OnPreLoadScreenManagerCleanUp` delegate once engine startup loading finishes

> **Loading Phase:** `PreLoadingScreen` — Loaded before all other modules.

## Integration with MES

`UModularExperienceManagerComponent` implements `IModularLoadingProcessInterface`:

```cpp
bool UModularExperienceManagerComponent::ShouldShowLoadingScreen(FString& OutReason) const
{
    if (LoadState != EExperienceLoadState::Loaded)
    {
        OutReason = TEXT("Experience loading...");
        return true;
    }
    return false;
}
```

This ensures the loading screen automatically stays visible while the experience is loading. Once the experience is fully loaded, `ShouldShowLoadingScreen` returns false and the loading screen is dismissed.

## Dependencies

### ModularLoadingScreen

| Type    | Modules                                                                                             |
| ------- | --------------------------------------------------------------------------------------------------- |
| Public  | Core                                                                                                |
| Private | CoreUObject, Engine, Slate, SlateCore, InputCore, PreLoadScreen, RenderCore, DeveloperSettings, UMG |

### ModularStartupLoadingScreen

| Type    | Modules                                                                              |
| ------- | ------------------------------------------------------------------------------------ |
| Public  | Core                                                                                 |
| Private | CoreUObject, Engine, Slate, SlateCore, MoviePlayer, PreLoadScreen, DeveloperSettings |
