Skip to content
This repository has been archived by the owner on May 9, 2023. It is now read-only.

Initialization

Sinai edited this page Jan 30, 2022 · 4 revisions

To use UniverseLib, something must first Initialize it. To be safe, you should always call Initialize yourself, multiple calls to Initialize will not cause any issues with UniverseLib.

UniverseLib has a method in the main Universe class called Init. This method has the following effects:

  • Immediately initializes ReflectionUtility, RuntimeHelper, ConfigManager and all Utility classes.
  • Begins a coroutine which waits for the startupDelay, then initializes InputManager and UniversalUI.

If you are using any UI features, you should wait until after UniverseLib's startup delay to create them. The Initialize method accepts an onInitialized action which will be invoked after the delay for convenience.

Any calls to InputManager before UniverseLib has initialized will return default, but will not throw exceptions.

If you are not using any UI features, in most cases you can call the method without any overloads:

UniverseLib.Universe.Init();

If you are using UI features or you require a finer degree of control over the startup process, use the full overload. The UniverseLibConfig takes non-null values from the config and applies them to the ConfigManager class.

void MyModEntryPoint()
{
    float startupDelay = 1f;
    UniverseLib.Config.UniverseLibConfig config = new()
    {
        Disable_EventSystem_Override = false, // or null
        Force_Unlock_Mouse = true, // or null
        Unhollowed_Modules_Folder = System.IO.Path.Combine("Some", "Path", "To", "Modules") // or null
    };

    UniverseLib.Universe.Init(startupDelay, OnInitialized, LogHandler, config);
}

void OnInitialized() 
{
    // ...
}

void LogHandler(string message, LogType type) 
{
    // ...
}
Clone this wiki locally