logo SERENITY
Game Systems Foundation
Search Results for

    Show / Hide Table of Contents

    Class UnityGameSettingsAssetPreloader

    Progressive asset preloader for menu-based game settings.

    SYSTEM DESIGN: This component implements progressive asset preloading for Unity game menus to create a fluid user experience. It analyzes UnityGameSettingsDefinition configurations and predictively preloads assets that users are likely to select.

    PRELOADING STRATEGIES:

    • SELECTABLE Components: Preloads current + neighbor values (sliding window: i-1, i, i+1)
    • DROPDOWN Components: Preloads current page elements (5 visible options around selection)
    • SLIDER/TOGGLE Components: Preloads current value only

      MEMORY MANAGEMENT:
    • Context-based asset separation to prevent conflicts
    • Automatic cleanup when leaving menu sections
    • Configurable limits for concurrent preloads

      INTEGRATION POINTS:
    • Menu lifecycle events (display, selection change, value submission)
    • IAssetPrefetcherApp service for actual preloading operations
    • IGameSettingsService for menu configuration data

      NOTE: This is a design template. Full implementation requires proper assembly references to Serenity.AssetPrefetcher.Application and Serenity.Ui.Domain assemblies.
    Inheritance
    object
    UnityGameSettingsAssetPreloader
    Implements
    IGameSettingsAssetPreloader
    Namespace: Serenity.GameSettings.Infrastructure.Services
    Assembly: Serenity.UnityGlobal.Infrastructure.dll
    Syntax
    public class UnityGameSettingsAssetPreloader : MonoBehaviour, IGameSettingsAssetPreloader

    Constructors

    UnityGameSettingsAssetPreloader()

    Declaration
    public UnityGameSettingsAssetPreloader()

    Methods

    AnalyzeAndPreloadMenuAsync(string, object[])

    Analyzes a menu and preloads assets for all available options.
    This is the main entry point for menu-level preloading.

    Declaration
    public Task AnalyzeAndPreloadMenuAsync(string menuId, object[] options)
    Parameters
    Type Name Description
    string menuId

    Menu identifier

    object[] options

    Array of UI options in the menu (when types are available: UiOption[])

    Returns
    Type Description
    Task

    A task representing the asynchronous operation

    Initialize(object, IGameSettingsService, ILogService)

    Initializes the asset preloader with required services.

    Declaration
    public void Initialize(object assetPrefetcher, IGameSettingsService gameSettingsService, ILogService logService)
    Parameters
    Type Name Description
    object assetPrefetcher

    Asset prefetcher service for preloading operations

    IGameSettingsService gameSettingsService

    Game settings service for accessing configurations

    ILogService logService

    ReleaseMenuAssets(string)

    Releases all preloaded assets for a specific menu to free memory.

    Declaration
    public void ReleaseMenuAssets(string menuId)
    Parameters
    Type Name Description
    string menuId

    Menu identifier whose assets should be released

    TriggerManualMenuAnalysis(string)

    Manually triggers preloading analysis for a specific menu.
    Useful for testing or external integration scenarios.

    Declaration
    public void TriggerManualMenuAnalysis(string menuId)
    Parameters
    Type Name Description
    string menuId

    The ID of the menu to analyze and preload

    UpdateSelectionPreloadAsync(string, int, object[])

    Updates preloading based on user's current selection in a menu.
    Implements sliding window preloading for neighboring options.

    Declaration
    public Task UpdateSelectionPreloadAsync(string menuId, int selectedIndex, object[] options)
    Parameters
    Type Name Description
    string menuId

    Menu identifier

    int selectedIndex

    Currently selected option index

    object[] options

    All available options in the menu

    Returns
    Type Description
    Task

    A task representing the asynchronous operation

    Implements

    IGameSettingsAssetPreloader
    In this article
    © 2026 Serenity. All Rights Reserved