Skip to main content
Applies to: Molca Core

Overview

This recipe shows you how to load Addressable content packages at runtime using the PackageSubsystem and IPackageService. Content packages enable downloadable or remotely updated scenarios, asset bundles, and other Addressables-driven payloads that integrate with Molca’s runtime package service. You’ll learn how to configure packages, load them asynchronously, access loaded assets, and handle loading errors.

Prerequisites

Step-by-step

Step 1: Configure content packages in your project

Set up Addressables groups and configure the ContentPackageSettings module in Global Settings.
Why this works: The Addressables system generates asset bundles and catalogs during build. The ContentPackageSettings module tells PackageSubsystem where to find remote catalogs and how to manage the download queue.

Step 2: Access PackageSubsystem after initialization

Use RuntimeManager.GetSubsystem<PackageSubsystem>() to access the package service after initialization completes.
Why this works: RuntimeManager.WaitForInitialization() ensures that all RuntimeSubsystem components (including PackageSubsystem) are initialized before you access them. The PackageService property provides the IPackageService interface for loading packages.

Step 3: Load a content package asynchronously

Use the IPackageService API to queue and load content packages. Handle the async operation with proper error checking.
Why this works: The IPackageService manages the download queue and handles Addressables catalog loading. Using async/await prevents blocking the main thread during downloads.

Step 4: Access loaded assets from the package

Once a package is loaded, use Addressables API to instantiate or load assets by label or address.
Why this works: After the package catalog is loaded via PackageSubsystem, the Addressables system knows about the assets. You can then use standard Addressables API (LoadAssetAsync, InstantiateAsync) to access them.

Step 5: Handle loading errors and retry logic

Implement error handling and retry logic for network failures or missing packages.
Why this works: Network downloads can fail due to connectivity issues. Retry logic with exponential backoff improves reliability. Always provide user feedback during long downloads.

Complete example

Here’s a complete example showing package loading with progress tracking and error handling:
This example demonstrates:
  • Proper initialization sequence with WaitForInitialization()
  • Null checks for PackageSubsystem and PackageService
  • Retry logic for network failures
  • Loading assets from the package using Addressables
  • Dependency injection for runtime-created objects
  • Cleanup in OnDestroy

Troubleshooting

  • PackageSubsystem or PackageService is null: Ensure the RuntimeManager prefab includes a PackageSubsystem component. Verify that RuntimeManager.WaitForInitialization() completes before accessing the subsystem. Check that ContentPackageSettings is configured in Global Settings.
  • Downloads never start or queue looks stuck: Confirm ContentPackageSettings configuration in Global Settings. Verify Addressables labels/paths match your configuration. Check platform build output and remote catalog URLs. Review Unity console for package-specific logs.
  • Wrong or missing bundle after Addressables build: Run a clean Addressables build (Clear Build Cache, then New Build). Verify remote catalog URLs and profile settings. Confirm AddressablesBuildNotificationProvider behavior for your Unity/Addressables version.
  • Content loads in Editor but not in player: Compare Addressables Play Mode Script (Fast Mode, Virtual Mode, Packed Mode) vs standalone build configuration. Verify CCD/remote hosting is accessible. Ensure initialization order awaits WaitForInitialization() before using PackageService.
  • Asset not found after package loads: Verify the asset address or label matches exactly (case-sensitive). Check that the asset is included in the Addressables group and built into the catalog. Use Addressables Event Viewer (Window → Asset Management → Addressables → Event Viewer) to debug load operations.