Skip to main content

Initialization

This guide describes the mod.io Unreal Engine plugin's basic event loop, initialization, and shutdown functions.

Ideally, you should wrap these functions in a separate subsystem (e.g. ModioManagerSubsystem) which is responsible for managing the full initialization and authentication flow for your game.

This guide covers:

Calling RunPendingHandlers

Before initializing the plugin, ensure RunPendingHandlers is being continually called. You can do this yourself in your project’s main loop, or by setting Use Background Thread to true in the mod.io project settings. For best performance, RunPendingHandlers should be called at least once per frame. See Maintaining the plugin event loop for additional information.

Initialization process

The mod.io Unreal Engine plugin is initialized by calling InitializeAsync, passing in a ModioInitializeOptions with the relevant information for the current session, and a callback containing a ModioErrorCode that will contain the result of the initialization on completion.

Use GetProjectInitializeOptionsForSessionId to initialize the plugin using the information entered in the mod.io project settings. On Windows, GetDefaultSessionIdWindows can be used as the Session ID. Some platforms also require additional parameters added to ModioInitializeOptions.ExtendedInitializationParameters. Refer to the relevant platform documentation for more information.

run_pending_handlers

initasync_getoptions

note
  • The error-handling in this sample has been omitted. See our Error Handling quick-start guide for more information.
  • InitializeAsync is a asynchronous function, therefore you must wait for the callback for confirmation that the initialization is complete.

Shutdown process

The mod.io Unreal Engine plugin is shut down by calling ShutdownAsync in a similar fashion.

shutdownasync_runhandlers

note
  • You must continue to call RunPendingHandlers while shutdown is in progress to allow intermediate handlers to complete.
  • Any in-flight mod.io async calls will complete with an error code indicating cancellation.
  • You must not call ShutdownAsync from within another completion handler/callback. This may cause the application to deadlock.

Next steps

Now that you have set up the Unreal Engine Plugin, you may want to learn more about the Plugin Structure to get a better understanding of the plugin itself and processes such error handling and user sessions.

Or if you are eager to get things moving, you can skip directly to setting up User Authentication or Adding UGC.

All our core plugin guides found at the Unreal Getting Started Guides are designed to teach you how to implement the fundamentals of the Unreal Engine Plugin.