-
Notifications
You must be signed in to change notification settings - Fork 53
Initialization
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 allUtility
classes. - Begins a coroutine which waits for the
startupDelay
, then initializesInputManager
andUniversalUI
.
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)
{
// ...
}