Skip to content

Initialisation and Scene Loading

Thane5 edited this page Sep 10, 2025 · 2 revisions

The "Systems" Prefab

At the heart is a prefab named "Systems", which has all the core classes of the game. It is stored in the "/Resources" folder, meaning it can be accessed by simply calling Resources.Load("Systems").

Image

Its most important classes are

  • PathManager
  • ConfigManager
  • InputManager
  • UIManager

Those are added as components on Awake: pathManager = gameObject.AddComponent<PathManager>();

Their variables are static and meant to be globally accessible, for example when you want to get the Redguard directory: Game.pathManager.GetRootFolder()

Bootstrapper

The Bootstrapper instantiates the Systems prefab as DontDestroyOnLoad:

public static class Bootstrapper
{
    [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
    public static void Execute()
    {
        Object.DontDestroyOnLoad(Object.Instantiate(Resources.Load("Systems")));
    }
}

It gets called automatically before the start of the game, and does not require a reference in the scene. This means that the prefab will be spawned now matter what scene you are using as an entry point.

Special Scenes

Beeing able to start from any scene is great because it simplifies testing in the editor.

To make this work, i also added a "Setup" screen that pops up anytime when there is no Redguard path configured. This is simply another scene, that gets loaded on top of the current one.

Image

For builds, "Launcher" is meant to be the default scene on top of the scene list. This allows users to go either into the main game, or open the modelviewer.

Image
Clone this wiki locally