BootstrapSystem - jimdroberts/FishMMO GitHub Wiki

Description

Base class for bootstrap systems in FishMMO. Handles asset and scene loading, progress tracking, and initialization flow for both editor and runtime environments, providing a unified entry point for staged loading and system startup.


API Access

Fields

  • public List EditorPreloadAssets

    Assets to preload in the editor before scene loading.

  • public List EditorPostloadAssets

    Assets to load after scene loading in the editor.

  • public List EditorPreloadScenes

    Scenes to preload in the editor.

  • public List EditorPostloadScenes

    Scenes to load after preloading in the editor.

  • public List PreloadAssets

    Assets to preload in standalone builds.

  • public List PostloadAssets

    Assets to load after scene loading in standalone builds.

  • public List PreloadScenes

    Scenes to preload in standalone builds.

  • public List PostloadScenes

    Scenes to load after preloading in standalone builds.

  • public List WebGLPreloadAssets

    Assets to preload in WebGL builds.

  • public List WebGLPostloadAssets

    Assets to load after scene loading in WebGL builds.

  • public List WebGLPreloadScenes

    Scenes to preload in WebGL builds.

  • public List WebGLPostloadScenes

    Scenes to load after preloading in WebGL builds.

Methods

  • public virtual void StartBootstrap()

    Initiates the asset and scene loading process for this bootstrap system. Should be called explicitly, typically by a previous BootstrapSystem after a scene has been loaded.

  • private void OnInternalLogCallback(string message)

    Callback for internal logging messages from FishMMO.Logging.Log. Ensures UnityLoggerBridge does not re-capture internal log calls. message: string - The log message.

  • public virtual void OnCompleteProcessing()

    Called immediately after the BootstrapSystem has completed its full loading process (Preload & Postload). Triggers the loading of the next scene in a sequential flow.

  • public virtual void OnCompletePreload()

    Called when Preload is completed. Triggers postload initialization.

  • public virtual void OnPreload()

    Called immediately after Preload Scenes are enqueued to the Load Processor. Override for custom logic.

  • public void InitializePreload()

    Initializes the preload asset and scene loading process.

  • public void AddressableLoadProcessor_OnPreloadProgressUpdate(float progress)

    Called after Preload is completed. Handles progress update and triggers postload. progress: float - The progress value (0.0 to 1.0).

  • public void InitializePostload()

    Initializes the postload asset and scene loading process.

  • public virtual void OnPostLoad()

    Called immediately after Postload Scenes are enqueued to the Load Processor. Override for custom logic.

  • public void AddressableLoadProcessor_OnPostloadProgressUpdate(float progress)

    Called after Postload is completed. Handles progress update and triggers completion processing. progress: float - The progress value (0.0 to 1.0).

  • void OnDestroy()

    Unity OnDestroy message. Handles cleanup when the object is destroyed.

  • public virtual void OnDestroying()

    Called when the object is being destroyed. Override for custom cleanup logic.

  • public void OnBootstrapPostProcess(Scene scene)

    Called after a scene is loaded to process bootstrap systems in the new scene. scene: Scene - The loaded scene.

  • private List OnScenePostProcess(Scene scene)

    Finds all BootstrapSystem components in the root objects of the given scene. scene: Scene - The scene to search. Returns: List of found BootstrapSystem components.


Basic Usage

Setup

  1. Inherit from BootstrapSystem for any system that requires staged asset and scene loading.
  2. Configure preload and postload asset/scene lists for each build target as needed.
  3. Call StartBootstrap to begin the loading process, typically from another BootstrapSystem or at scene start.
  4. Override OnPreload, OnPostLoad, OnCompletePreload, and OnCompleteProcessing for custom logic at each stage.

Example

// Example 1: Creating a custom bootstrap system
public class MyBootstrapSystem : BootstrapSystem
{
    public override void OnPreload()
    {
        // Custom logic before preload
    }
    public override void OnCompleteProcessing()
    {
        // Custom logic after all loading is complete
    }
}

// Example 2: Starting the bootstrap process
myBootstrapSystem.StartBootstrap();

Best Practices

  • Use separate preload and postload lists for editor, standalone, and WebGL to optimize loading for each environment.
  • Always call StartBootstrap explicitly to control the loading sequence.
  • Override completion and progress methods to chain loading flows or trigger dependent systems.
  • Clean up event handlers and logging callbacks in OnDestroying to prevent memory leaks.
  • Use OnBootstrapPostProcess to discover and start additional bootstrap systems in loaded scenes.
⚠️ **GitHub.com Fallback** ⚠️