How tuyoogame/yooasset works
1. Repository shape
This is a Unity package-style repository for YooAsset, centered under Assets/YooAsset. It is split into three major areas: Runtime for player-side asset management, Editor for authoring/build tooling, and Samples~ for usage examples and test content. The package is published via Assets/YooAsset/package.json and separated into asmdefs for editor/runtime boundaries.
2. Core runtime entry points
Runtime/YooAssets.cs, YooAssetsDriver.cs, and YooAssetsExtension.cs act as the public façade and Unity integration layer. They provide the main API surface that game code uses to initialize the system, choose a play mode, request assets, and drive async operations through Unity’s update loop.
3. Resource-package layer
Runtime/ResourcePackage is the domain model for package metadata and lifecycle. It contains manifests, bundles, assets, package details, and play mode abstractions. This layer decides what content exists, what version is active, and how to resolve bundle/asset relationships before anything is loaded.
4. File-system abstraction boundary
Runtime/FileSystem is the main runtime boundary between package logic and actual file access. Different concrete file systems model the deployment mode: built-in/local files, cache-backed online files, editor-simulated files, unpacked local bundles, web remote loading, web server loading, and web game variants. This is the key architectural seam where the same higher-level asset request can be served from local disk, cache, or network.
5. Load/download execution model
Most runtime work is expressed as async operations under Runtime/OperationSystem and the many Operation classes nested throughout ResourcePackage, FileSystem, ResourceManager, and DownloadSystem. The system is built around an internal async-operation base and status model, so initialization, manifest loading, version requests, downloads, bundle loads, and unloads are all stepwise tasks rather than direct blocking calls.
6. Resource manager and handle model
Runtime/ResourceManager owns asset acquisition and lifetime management. It exposes handles for assets, scenes, raw files, sub-assets, and all-assets loads, and uses provider objects plus internal load-bundle operations to coordinate actual bundle access. This layer is where reference counting and unloading behavior are enforced.
7. Download subsystem
Runtime/DownloadSystem encapsulates network file retrieval, including Unity web request wrappers and counters for tracking active requests. It is used by cache/web file systems to fetch package versions, manifests, hashes, and bundle payloads, including support for local-file and resume-style operations in the cache path.
8. Initialization and update flow
A typical runtime flow is: initialize YooAssets with settings, select a play mode, create/open a ResourcePackage, request package version, update the package manifest, initialize the selected file system, then load assets/bundles through the resource manager. If content is missing locally, the cache/web file systems trigger download operations before the final asset load completes.
9. Diagnostics and remote debugging
Runtime/DiagnosticSystem provides runtime inspection data and remote debugger transport. It models debug reports for packages, bundles, providers, and operations, and supports editor/player connection paths. This is the runtime visibility layer used by the debugger tooling in the editor and by sample monitoring code.
10. Editor tooling for content preparation
The editor side is split into four main tool areas: AssetBundleCollector, AssetArtScanner, AssetBundleBuilder, and reporting/debug windows. Collector defines grouping and pack rules; scanner defines schemas for asset-art analysis; builder turns collected assets into build maps and packages; reporter/scanner/debugger windows present the resulting data in UIElements-based tools.
11. Build pipeline architecture
Editor/AssetBundleBuilder/BuildPipeline contains multiple pipeline families: Builtin Build Pipeline, Scriptable Build Pipeline, Raw File Build Pipeline, and Editor Simulate Build Pipeline. Each pipeline is implemented as a sequence of build tasks such as prepare, get build map, update bundle info, encryption, building, copying built-in files, manifest/catalog creation, report creation, and verification. The architecture is task-based so the same build phases can be reused across different build backends.
12. Generated output and metadata
The build system emits package manifests, catalogs, reports, encrypted or copied files, and bundle artifacts that the runtime file systems consume. In other words, editor build output is not just bundles; it is a set of coordinated metadata files plus content files that drive versioning, integrity checks, and runtime loading.
13. Settings and extensibility
Runtime/Settings and Editor/SettingLoader centralize configuration, while Runtime/Services defines extension points for encryption, decryption, manifest processing/restoration, remote services, and local-file copying. This is the main customization boundary: projects can replace the default services without changing the core package internals.
14. Samples as reference architectures
The samples are not just demos; they show how the package is meant to be wired into real projects. Space Shooter demonstrates a full game using YooAsset for scenes, UI, shaders, bundles, and patch flow; Test Sample exercises initialization, editor/builtin/cache loading, encryption, unload, and downloader paths; Mini Game provides platform-specific file systems for WeChat, TikTok, Alipay, Taptap, and Google Play; UniTask Sample shows async integration. These samples are useful for understanding the intended subsystem boundaries and integration points.
Main entry points: IFileSystem.cs File Systems · ResourcePackage.cs ResourcePackage · YooAssets.cs YooAssets · AssetBundleBuilder.cs Builder
Components 24
Runtime
Player-side asset loading, package lifecycle, file systems, and async operations.
- YooAssets · Public entry point and Unity-facing API for package initialization, play modes, and asset requests.
Assets/YooAsset/Runtime/YooAssets.cs - Driver · Hooks the runtime into Unity update flow and lifecycle.
Assets/YooAsset/Runtime/YooAssetsDriver.cs - Extensions · Convenience extensions around the public API and async operations.
Assets/YooAsset/Runtime/YooAssetsExtension.cs - ResourcePackage · Package-level model for manifests, bundles, assets, versions, and play mode selection.
Assets/YooAsset/Runtime/ResourcePackage/ResourcePackage.cs - Manifest Model · Defines package manifests, bundle info, asset info, and resolution helpers.
Assets/YooAsset/Runtime/ResourcePackage/PackageManifest.cs - Play Modes · Selects editor-simulate, built-in, cache, or web-oriented package behavior.
Assets/YooAsset/Runtime/ResourcePackage/PlayMode/PlayModeImpl.cs - Async Ops · Base async-operation framework used across initialization, loading, downloading, and cleanup.
Assets/YooAsset/Runtime/OperationSystem/OperationSystem.cs - File Systems · Abstracts bundle and manifest access across local, cache, editor, web, and platform-specific modes.
Assets/YooAsset/Runtime/FileSystem/Interface/IFileSystem.cs - Built-in FS · Serves packaged content from built-in/local deployment files.
Assets/YooAsset/Runtime/FileSystem/DefaultBuildinFileSystem/DefaultBuildinFileSystem.cs - Cache FS · Maintains downloaded content, verification, and cache cleanup for online delivery.
Assets/YooAsset/Runtime/FileSystem/DefaultCacheFileSystem/DefaultCacheFileSystem.cs - Web FS · Loads manifests and bundles through remote web paths and request operations.
Assets/YooAsset/Runtime/FileSystem/DefaultWebRemoteFileSystem/DefaultWebRemoteFileSystem.cs - ResourceManager · Owns asset acquisition, handles, providers, reference counts, and unload behavior.
Assets/YooAsset/Runtime/ResourceManager/ResourceManager.cs - DownloadSystem · UnityWebRequest-based retrieval and request counting for version, manifest, hash, and bundle downloads.
Assets/YooAsset/Runtime/DownloadSystem/DownloadSystemHelper.cs - Diagnostics · Runtime inspection data and remote debugger transport for packages, bundles, providers, and operations.
Assets/YooAsset/Runtime/DiagnosticSystem/DebugReport.cs
Editor
Collector, scanner, build pipeline, reporting, and debugger tooling.
- Collector · Defines collector packages, groups, and pack/address/filter rules for build input.
Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollector.cs - Scanner · Scans assets against schemas and produces art/reporting data.
Assets/YooAsset/Editor/AssetArtScanner/AssetArtScanner.cs - Builder · Coordinates build parameters, build maps, and pipeline selection for package output.
Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilder.cs - Build Pipelines · Task-based builtin, scriptable, raw-file, and editor-simulate build backends.
Assets/YooAsset/Editor/AssetBundleBuilder/BuildPipeline/ScriptableBuildPipeline/ScriptableBuildPipeline.cs - Reporter · Summarizes bundles, assets, and build results for inspection and comparison.
Assets/YooAsset/Editor/AssetBundleReporter/AssetBundleReporterWindow.cs - Debugger · Editor-side window and remote session for package, bundle, and operation visibility.
Assets/YooAsset/Editor/AssetBundleDebugger/AssetBundleDebuggerWindow.cs
Samples
Reference integrations and example content for runtime and editor flows.
- Space Shooter · End-to-end game sample showing patch flow, scenes, UI, assets, and gameplay integration.
Assets/YooAsset/Samples~/Space Shooter/GameScript/Runtime/Boot.cs - Test Sample · Exercises initialization, file systems, encryption, unloading, downloader, and async load paths.
Assets/YooAsset/Samples~/Test Sample/Runtime/T0_InitYooAssets/T0_InitYooAssets.cs - Mini Game · Implements platform-specific file systems for mini-game environments such as WeChat, TikTok, Alipay, Taptap, and Google Play.
Assets/YooAsset/Samples~/Mini Game/Runtime/WechatFileSystem/WechatFileSystem.cs - UniTask Sample · Demonstrates async integration extensions for YooAsset operations.
Assets/YooAsset/Samples~/UniTask Sample/UniTask/Runtime/External/YooAsset/AsyncOperationBaseExtensions.cs
Connections 26
- YooAssets → ResourcePackage: creates packages · API entry creates or opens resource packages.
- YooAssets → Driver: driven by · Runtime is advanced through Unity lifecycle hooks.
- YooAssets → Extensions: extended by · Convenience wrappers build on the public API.
- ResourcePackage → Manifest Model: uses · Package state is defined by manifests, bundles, and assets.
- ResourcePackage → Play Modes: selects · Package behavior changes by play mode strategy.
- ResourcePackage → Async Ops: runs via · Package actions are executed as async operations.
- ResourcePackage → File Systems: opens through · Package loading is routed through a file-system boundary.
- Async Ops → ResourceManager: orchestrates · Resource manager work is exposed as async operations.
- ResourceManager → File Systems: loads from · Asset and bundle retrieval depends on the selected file system.
- File Systems → Built-in FS: local mode · Built-in deployment reads packaged local content.
- File Systems → Cache FS: online cache · Cache-backed mode manages downloads and verified local copies.
- File Systems → Web FS: remote mode · Web-oriented modes fetch manifest and bundle data remotely.
- Cache FS → DownloadSystem: fetches · Cache population and updates rely on network downloads.
- Web FS → DownloadSystem: requests · Remote file systems delegate retrieval to download operations.
- Diagnostics → Driver: observes · Debugger transport is attached to runtime updates and state.
- Collector → Builder: feeds · Collected groups and rules become build input.
- Scanner → Reporter: produces · Scanner data is surfaced through reporting and inspection UI.
- Builder → Build Pipelines: executes · Build orchestration selects a concrete task pipeline.
- Build Pipelines → Reporter: emits · Build output and reports are consumed by reporting tools.
- Builder → Manifest Model: generates · Build output includes manifests and catalogs used at runtime.
- Space Shooter → YooAssets: uses · Sample gameplay initializes and loads through the public API.
- Space Shooter → Collector: configured by · Sample content is organized by collector settings.
- Test Sample → YooAssets: exercises · Sample scenes validate runtime initialization and loading paths.
- Mini Game → File Systems: customizes · Sample platform backends implement specialized file systems.
- UniTask Sample → Extensions: adapts · Async sample extends operation/handle awaitability.
- Debugger → Diagnostics: consumes · Editor debugger views remote/runtime diagnostic data.