YooAsset Documentation

repository·yoo3·Indexed 24 days ago

https://github.com/tuyoogame/yooasset

A professional-grade resource management system for Unity3D (version 3.0.5) designed for large-scale game assets, multi-platform distribution, and complex deployment scenarios such as zero-resource installs. It includes specialized support for WebGL mini-game platforms including Alipay, Kuaishou, OPPO, TapTap, and vivo.

Tokens
5K
Snippets
8
Records
29
Agent score
85%

What's inside YooAsset

  1. Overview of YooAsset Resource Management System

    yoo3

    YooAsset is a resource management system for Unity3D designed to help development teams deploy and deliver games efficiently. It is suitable for commercial games and has been validated by products with millions of DAU (Daily Active Users).

    Key Use Cases:

    • Zero-resource installation packages: Release a small initial package and download assets while playing.
    • Tiered content delivery: Provide a guaranteed initial experience, then allow players to download specific levels or content.
    • Size-constrained packages: Keep initial downloads under specific limits (e.g., 300MB) by downloading remaining content before game entry.
    • Offline/Online hybrid support: Support normal updates when online, while allowing play of older versions when offline.
    • MOD support: Enable players to upload MOD content to servers for others to download and play.
    • Large-scale project management: Support distributed builds for projects with hundreds of GBs of resources to reduce build times.
  2. Key Features of YooAsset

    yoo3

    YooAsset provides a comprehensive suite of features for asset management:

    Build & Packaging

    • Seamless Build Pipeline Switching: Supports both traditional built-in pipelines and programmable build pipelines (SBP).
    • Distributed Building: Supports building by project or by content, facilitating MOD development.
    • Addressable Resource Locating: Supports both full-path and addressable resource locating.
    • Secure & Efficient Bundling: Uses a resource tag-based bundling scheme that automatically classifies dependencies to avoid manual maintenance.
    • Flexible Packaging System: Allows custom packaging strategies with automatic dependency analysis to ensure zero redundancy and prevent circular dependencies.

    Runtime & Loading

    • Reference Counting: Uses a reference counting management scheme for safe resource unloading and memory management. Includes an analyzer to detect potential resource leaks.
    • Multiple Runtime Modes: Easily switch between Editor Simulation, Single-player (Local), Online, and WebGL modes without code changes.
    • Robust Loading System:
      • Asynchronous Loading: Supports Coroutines, Tasks, and Delegates.
      • Synchronous Loading: Supports mixed use of synchronous and asynchronous loading.
      • On-demand Downloading: Automatically downloads missing resource bundles from the server during the loading process.
      • Multi-threaded Downloading: Supports breakpoint resumption, automatic file verification, and automatic repair of corrupted files.
      • Versatile Downloaders: Create downloaders based on resource tags or specific resource objects. Supports limiting concurrent downloads, setting retry counts, and configuring timeouts. Provides progress tracking and failure callbacks.

    Management & Platform Support

    • Native File Management: Seamlessly manages and downloads native files alongside the resource system.
    • Version Management: Supports quick rollbacks, distinguishing between audit/test/live versions, and gray-scale updates.
    • Multi-platform Support: Supports Android, iOS, PC, and WebGL. (Note: 2.x versions specifically support WeChat and Douyin mini-games).
  3. Initialize YooAsset with TaptapFileSystemCreater

    yoo3

    When initializing WebPlayModeOptions for a TapTap Mini Game build, use TaptapFileSystemCreater.CreateFileSystemParameters to configure the file system. This allows the underlying TapTap platform adapter to handle remote AssetBundle requests.

    Note that even though the platform handles the requests, your business logic should continue to use the standard YooAsset remote asynchronous loading workflow.

    #if UNITY_WEBGL && TAPMINIGAME && !UNITY_EDITOR
    var createParameters = new WebPlayModeOptions();
    
    string defaultHostServer = GetHostServerURL();
    string fallbackHostServer = GetHostServerURL();
    IRemoteService remoteService = new RemoteService(defaultHostServer, fallbackHostServer);
    
    createParameters.WebServerFileSystemParameters =
        TaptapFileSystemCreater.CreateFileSystemParameters(remoteService);
    
    var initializationOperation = package.InitializePackageAsync(createParameters);
    #endif
  4. Use HashName for resource bundle naming on OPPO

    yoo3

    OPPO identifies cacheable resources using the hash within the remote filename. To ensure maximum compatibility with OPPO's caching rules and to avoid exposing original bundle names, YooAsset recommends using the HashName naming convention.

    Avoid: BundleName or BundleName_HashName for OPPO cache builds.

    Example of HashName output: 8d265a9dfd6cb7669cdb8b726f0afb1e.bundle

  5. Configure AssetBundle naming for vivo Mini Game

    yoo3

    The vivo Mini Game platform's underlying cache relies on the hash within the AssetBundle filename.

    To ensure maximum compatibility and avoid exposing original bundle names, YooAsset recommends using the HashName naming style. This generates filenames consisting only of a hash, such as 8d265a9dfd6cb7669cdb8b726f0afb1e.bundle.

    Avoid using BundleName or BundleName_HashName for vivo Mini Game builds.

  6. Setup UniTask support (Source Code Method)

    yoo3

    If you are using the UniTask source code directly, follow these steps to enable YooAsset integration:

    1. Download and import UniTask source code into your project.
    2. Modify UniTask/Runtime/_InternalVisibleTo.cs to include the YooAsset assembly visibility:
      [assembly: InternalsVisibleTo("UniTask.YooAsset")] // Add this line
    3. Copy the YooAsset extension scripts from YooAssets/Samples/UniTask Sample/UniTask into your project.
    4. Add the following symbol to your Scripting Define Symbols in Project Settings > Player > Scripting Define Symbols: YOOASSET_UNITASK_SUPPORT
    5. Restart the Unity engine.
  7. Initialize YooAsset with Alipay File System

    yoo3

    When initializing WebPlayModeOptions for an Alipay Mini Game build, use AlipayFileSystemCreater.CreateFileSystemParameters to generate the file system parameters.

    Note that the Alipay Mini Game platform handles remote AssetBundle requests at a low level; your business logic should continue to use the standard YooAsset remote asynchronous loading workflow.

    #if UNITY_WEBGL && UNITY_ALIMINIGAME && !UNITY_EDITOR
    var createParameters = new WebPlayModeOptions();
    
    string defaultHostServer = GetHostServerURL();
    string fallbackHostServer = GetHostServerURL();
    IRemoteService remoteService = new RemoteService(defaultHostServer, fallbackHostServer);
    
    createParameters.WebServerFileSystemParameters =
        AlipayFileSystemCreater.CreateFileSystemParameters(remoteService);
    
    var initializationOperation = package.InitializePackageAsync(createParameters);
    #endif
  8. Configure AssetBundle Naming for TapTap Mini Games

    yoo3

    For TapTap Mini Game builds, it is highly recommended to use the HashName naming convention. This generates pure hash filenames (e.g., 8d265a9dfd6cb7669cdb8b726f0afb1e.bundle), which is better for platform caching, update identification, and security (avoiding exposure of original bundle names).

    Avoid using BundleName or BundleName_HashName for TapTap Mini Game builds.

  9. Setup UniTask support (Package Method)

    yoo3

    If you are using UniTask via a Unity Package, follow these steps:

    1. Import the UniTask plugin via Package Manager.
    2. Copy the YooAsset extension scripts from YooAssets/Samples/UniTask Sample/UniTask and YooAssets/Samples/UniTask Sample/UniTaskRef into your project.
    3. Add the following symbol to your Scripting Define Symbols in Project Settings > Player > Scripting Define Symbols: YOOASSET_UNITASK_SUPPORT
    4. Restart the Unity engine.
  10. Setup YooAsset for TapTap Mini Games

    yoo3

    To use YooAsset in a TapTap Mini Game WebGL environment, you must first install the TapTap Mini Game Unity/Tuanjie WebGL Adaptation SDK and switch your project build target to WebGL.

    Enable the TAPMINIGAME scripting define symbol in your WebGL Player settings. This macro is used by YooAsset to maintain consistency with other mini-game platform adaptation code.

    If you encounter compilation errors stating that TapTapMiniGame, TapAssetBundle, or DownloadHandlerTapAssetBundle cannot be found, ensure the TapTap SDK is imported and that the TapTap SDK assembly is added to the YooAsset.MiniGame.asmdef assembly reference.