ClientPostbootSystem - jimdroberts/FishMMO GitHub Wiki

Description

Manages the client-side post-boot operations, including camera state management and scene loading. Handles addressable asset loading/unloading and integrates with the client for postload scene management in FishMMO.


API Access

Fields

  • private Vector3 cameraInitialPosition

    Stores the initial position of the main camera for scene reloads.

  • private Quaternion cameraInitialRotation

    Stores the initial rotation of the main camera for scene reloads.

Methods

  • public override void OnPreload()

    Called during preload phase. Captures initial camera state and loads template cache.

  • public override void OnDestroying()

    Called when the system is being destroyed. Unsubscribes from addressable events.

  • public void AddressableLoadProcessor_OnAddressableLoaded(UnityEngine.Object addressable)

    Handler for when an addressable asset is loaded. Adds it to the cache if possible. Parameters: - UnityEngine.Object addressable: The loaded addressable Unity object.

  • public void AddressableLoadProcessor_OnAddressableUnloaded(UnityEngine.Object addressable)

    Handler for when an addressable asset is unloaded. Removes it from the cache if possible. Parameters: - UnityEngine.Object addressable: The unloaded addressable Unity object.

  • public void SetClient(Client client)

    Sets up client event handlers for scene management. Parameters: - Client client: The client instance.

  • public void UnsetClient(Client client)

    Removes client event handlers for scene management. Parameters: - Client client: The client instance.

  • private void UnloadPostloadScenes()

    Unloads postload scenes using the addressable load processor.

  • private void ReloadPostloadScenes()

    Reloads postload scenes and resets the camera to its initial state.


Basic Usage

Setup

  1. Attach the ClientPostbootSystem to a GameObject that persists across scenes.
  2. Ensure it is initialized before postload scene management is required.
  3. Use SetClient to register event handlers with the main client instance.
  4. The system will automatically manage camera state and postload scenes on login/logout events.

Example

// Example 1: Registering with the client
clientPostbootSystem.SetClient(client);

// Example 2: Unregistering on shutdown
clientPostbootSystem.UnsetClient(client);

Best Practices

  • Always unregister event handlers in OnDestroying or when the client is destroyed.
  • Use this system to manage persistent scene content and camera state between world transitions.
  • Ensure addressable assets are properly labeled for postload management.
⚠️ **GitHub.com Fallback** ⚠️