gamedev-unity/skills/unity-skills/skills/yooasset-design/SKILL.md
Source-anchored design rules for YooAsset v2.3.18 — initialization, default-package shortcuts, play modes, asset handles, loading, updates, filesystem, build, and pitfalls. Use when writing or reviewing YooAsset code, initializing packages, loading assets via handles, setting up hot-update/download, or choosing a play mode, even if the user just says "热更" or "资源包". 为 YooAsset v2.3.18 提供源码锚定的设计规则(初始化、默认包快捷方式、运行模式、资源句柄、加载、更新、文件系统、构建、陷阱);当用户要编写或审查 YooAsset 代码、初始化 package、用句柄加载资源、配置热更/下载、或选择运行模式时使用。
npx skillsauth add bernatmv/ai-rules unity-yooasset-designInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Advisory module. Every rule is distilled from YooAsset v2.3.18 (2025-12-04) source at Assets/YooAsset/. Each rule cites a concrete file/line so the reasoning is auditable and the AI does not improvise against stale memory.
Mode: Documentation only — no REST skills to gate; load freely under any operating mode (Approval / Auto / Bypass).
Load before writing or reviewing any of:
YooAssets.Initialize() / CreatePackage() / Destroy() bootstrap codeYooAssets.SetDefaultPackage(...), YooAssets.LoadAssetAsync(...), YooAssets.CreateResourceDownloader(...)ResourcePackage.InitializeAsync(...) with any of the 5 EPlayMode variantsLoadAssetSync/Async, LoadSubAssetsAsync, LoadAllAssetsAsync, LoadRawFileAsync, LoadSceneAsync and their matching Handle usage / releaseRequestPackageVersionAsync → UpdatePackageManifestAsync → CreateResourceDownloader → BeginDownloadFileSystemParameters construction (Buildin / Cache / Editor / WebServer / WebRemote / custom)IDecryptionServices / IRemoteServices / IWebDecryptionServices implementationsAssetBundleBuilder.Run(...) and AssetBundleCollector configurationEOperationStatus / EFileClearMode / PackageDetails| # | Rule | Source anchor |
|---|------|---------------|
| 1 | Call YooAssets.Initialize() before any CreatePackage() and keep it as a process-level singleton. A second call only logs a warning and returns, but normal architecture should gate it with YooAssets.Initialized. The call creates a [{nameof(YooAssets)}] driver GameObject via DontDestroyOnLoad to pump OperationSystem.Update(). Do not Destroy this driver yourself. | Runtime/YooAssets.cs:38-64 |
| 2 | ResourcePackage.InitializeAsync(...) has no separate EPlayMode argument: it infers play mode from the concrete InitializeParameters subclass. The five built-in subclasses map 1:1 to the five modes; an unknown subclass throws NotImplementedException, while a recognized but semantically wrong subclass wires the wrong file-system topology and fails later. | Runtime/ResourcePackage/ResourcePackage.cs:107-135, 170-181, Runtime/InitializeParameters.cs:8-110 |
| 3 | EditorSimulateMode works only when UNITY_EDITOR is defined; WebPlayMode works only when UNITY_WEBGL is defined (and every other mode is rejected on WebGL). | Runtime/ResourcePackage/ResourcePackage.cs:160-197 |
| 4 | Every AssetHandle / SubAssetsHandle / AllAssetsHandle / RawFileHandle / SceneHandle must be released via Release() or Dispose(). Without release, bundles never unload even with AutoUnloadBundleWhenUnused = true. | Runtime/ResourceManager/Handle/HandleBase.cs:21-40, Runtime/InitializeParameters.cs:48-49 |
| 5 | LoadAssetSync/Async performs a DEBUG-only type guard that rejects any Type derived from UnityEngine.Behaviour and any type not derived from UnityEngine.Object. Treat the restriction as architectural even though the guard is compiled out of non-DEBUG builds. | Runtime/ResourcePackage/ResourcePackage.cs:1172-1187 |
| 6 | YooAsset 2.3.18 includes default-package static shortcuts on YooAssets (SetDefaultPackage, Load*, CreateResourceDownloader, etc.). They are valid API, but architecture should prefer explicit ResourcePackage references in multi-package or library code. | Runtime/YooAssetsExtension.cs:16, 217-295, 479-506 |
| 7 | RequestPackageVersionAsync() returns RequestPackageVersionOperation (exposes .PackageVersion). There is no UpdatePackageVersionOperation class in 2.3.18 — if you think you remember one, you are confusing it with the older name. | Runtime/ResourcePackage/ResourcePackage.cs:225-231 |
| 8 | Before UpdatePackageManifestAsync, call UnloadAllAssetsAsync(); YooAsset logs a warning when loaders are still alive. | Runtime/ResourcePackage/ResourcePackage.cs:242-247 |
| 9 | Downloader callbacks (DownloadFinishCallback / DownloadUpdateCallback / DownloadErrorCallback / DownloadFileBeginCallback) must be assigned before BeginDownload(). They are delegate fields, not events — only one subscriber per slot. | Runtime/DownloadSystem + Runtime/ResourcePackage/Operation/DownloaderOperation.cs:86-101, 330-336 |
| 10 | ResourcePackage.DestroyAsync() must run before YooAssets.RemovePackage(). RemovePackage refuses when InitializeStatus != EOperationStatus.None. | Runtime/YooAssets.cs:177-190, Runtime/ResourcePackage/ResourcePackage.cs:210-218 |
| 11 | The patch flow is strictly ordered: InitializeAsync → RequestPackageVersionAsync → UpdatePackageManifestAsync(version) → CreateResourceDownloader → BeginDownload. Jumping ahead (e.g. loading assets between version and manifest) is unsupported. | Runtime/ResourcePackage/ResourcePackage.cs:225, 238, 972, Samples~/Space Shooter/.../PatchLogic/FsmNode/Fsm*.cs |
| Sub-doc | When to read |
|---------|--------------|
| INIT.md | Initialize / Destroy / CreatePackage / TryGetPackage / RemovePackage; single driver GameObject; OperationSystem loop |
| PLAYMODE.md | All 5 EPlayMode values, their matching InitializeParameters subclass, platform #if guards, and the runtime dispatch table |
| HANDLES.md | HandleBase API (Release / IsDone / Progress / Status / LastError / Completed / Task / IEnumerator), AssetHandle.Instantiate*, reference counting, AutoUnloadBundleWhenUnused |
| LOADING.md | LoadAsset, LoadSubAssets, LoadAllAssets, LoadRawFile, LoadScene — all overloads + Behaviour/Type rejection + LoadSceneParameters |
| UPDATE.md | Patch flow, RequestPackageVersionOperation, UpdatePackageManifestOperation, PreDownloadContentOperation, ResourceDownloaderOperation (4 callbacks, pause/resume/cancel, Combine) |
| FILESYSTEM.md | FileSystemParameters + 24 FileSystemParametersDefine constants + 5 factory helpers + IDecryptionServices / IRemoteServices / IWebDecryptionServices |
| BUILD.md | AssetBundleBuilder.Run(...), BuildParameters (Scriptable / Raw / Simulate), AssetBundleCollector, IFilterRule.FindAssetType, ScriptableBuildParameters.ReplaceAssetPathWithAddress |
| PITFALLS.md | 30 concrete hallucination pitfalls + legacy API migration section |
This document targets YooAsset 2.3.18 (2025-12-04). Key recent history:
UNPACK_FILE_SYSTEM_ROOT file-system parameter, EFileClearMode.ClearBundleFilesByLocations, RawFileBuildParameters.IncludePathInHash.AssetBundle load could block unload.timeout parameter (use DOWNLOAD_WATCH_DOG_TIME on the cache file system instead). IFilterRule gained a required FindAssetType property.FILE_VERIFY_MAX_CONCURRENCY, StripUnityVersion, preview UseWeakReferenceHandle (under YOOASSET_EXPERIMENTAL).Source: Assets/YooAsset/CHANGELOG.md:5-275.
| Legacy API (pre-2.3.18) | Status in 2.3.18 | Replacement | Source |
|-------------------------|------------------|-------------|--------|
| CreateResourceDownloader(count, retry, timeout) overload / ResourceDownloaderOperation.timeout property | Removed in 2.3.16 | Assign DOWNLOAD_WATCH_DOG_TIME on the CacheFileSystemParameters / BuildinFileSystemParameters | CHANGELOG.md:173-177, FileSystemParametersDefine.cs:18 |
| IFilterRule without a FindAssetType property | Breaking change in 2.3.16 — compilation breaks | Implement public string FindAssetType { get; } that returns a Unity asset-type filter string | CHANGELOG.md:179-192 |
| Old manifest binary (pre-2.3.15 client reading a 2.3.15+ manifest, or vice versa) | Wire-incompatible | Rebuild + re-ship installer; no runtime bridge exists | CHANGELOG.md:196-198 |
| YooAssets.LoadAsset(...) | Does not exist — method names include LoadAssetSync / LoadAssetAsync, not bare LoadAsset | package.LoadAssetAsync<T>(location) or YooAssets.LoadAssetAsync<T>(location) after SetDefaultPackage | Runtime/YooAssetsExtension.cs:217-295, Runtime/ResourcePackage/ResourcePackage.cs:641-732 |
| YooAssets.LoadAssetAsync(...) marked as hallucination | Outdated rule — 2.3.18 has this default-package shortcut | Prefer package.LoadAssetAsync<T>(location) for explicit ownership; static shortcut is acceptable only after YooAssets.SetDefaultPackage(package) | Runtime/YooAssetsExtension.cs:16, 260-295 |
| package.UnloadUnusedAssets() (synchronous) | Does not exist | package.UnloadUnusedAssetsAsync(int loopCount = 10) returns an UnloadUnusedAssetsOperation | Runtime/ResourcePackage/ResourcePackage.cs:355-361 |
| UpdatePackageVersionOperation class (often confused with the real type) | Does not exist | RequestPackageVersionOperation, with a .PackageVersion string property | Runtime/ResourcePackage/ResourcePackage.cs:225-231 |
| NetworkVariable<T> / OnValueChanged style sync for assets (leaked in from Netcode) | Does not exist in YooAsset | Subscribe AssetHandle.Completed event or await handle.Task / yield return handle | Runtime/ResourceManager/Handle/AssetHandle.cs:20-37, Runtime/ResourceManager/Handle/HandleBase.cs:152-173 |
| ResourceDownloaderOperation.OnDownloadFinishCallback (event-style) | Field is a plain delegate, not an event | Assign once: downloader.DownloadFinishCallback = OnFinish; — do not += (single-slot field) | Runtime/ResourcePackage/Operation/DownloaderOperation.cs:86-101 |
When in doubt, read the cited source — not your memory.
development
Keyword research and validation with real search-demand data — never ship keywords from intuition alone. Probes Google Autocomplete per language (free, no account) to prove demand and discover the exact phrasing people type, checks SERPs for winnability, and uses Keyword Planner/Ahrefs/Semrush exports when the user has access. Activates when: choosing or reviewing SEO keywords, meta keywords, page titles, article topics or slugs, landing page copy targeting search, App Store/ASO keyword fields, multilingual keyword sets, 'what should we rank for', 'keyword analysis', or auditing why a page doesn't rank. Also invoke it as a validation pass whenever another skill or task produces a keyword list.
development
Automate YooAsset hot-update and asset bundles — build bundles, run Editor simulate builds, manage Collector groups, analyze BuildReport, and validate runtime. Use when building or simulating YooAsset bundles, configuring collectors, or validating hot-update assets, even if the user just says "热更" or "打AB包". 自动化 YooAsset 热更新与资源包(构建 bundle、编辑器模拟构建、管理 Collector 分组、分析 BuildReport、运行时校验);当用户要构建或模拟 YooAsset 资源包、配置 collector、或校验热更资源时使用。
data-ai
Last-resort guidance for safely hand-editing Unity serialized YAML (.unity/.prefab/.asset/.meta/ProjectSettings) — reference/fileID repair, GUID safety, and merge-conflict fixes. Use when REST cannot reach the change and YAML must be hand-edited — fixing m_Script GUIDs, broken fileID references, .meta files, or merge conflicts, even if the user just says "场景文件打不开" or "引用丢了". 安全手编 Unity 序列化 YAML(.unity/.prefab/.asset/.meta/ProjectSettings)的最后手段(引用/fileID 修复、GUID 安全、合并冲突修复);当 REST 无法触达、必须手编 YAML 时使用——修复 m_Script GUID、断裂 fileID 引用、.meta 文件或合并冲突。
tools
Set up XR Interaction Toolkit (XRI) for VR/AR — XR rigs and grab/socket/ray interactors. Use when building VR/AR interaction, setting up an XR rig, or configuring grab/socket/ray interactors, even if the user just says "VR" or "XR交互". 搭建用于 VR/AR 的 XR Interaction Toolkit(XRI:XR rig、抓取/插槽/射线交互器);当用户要构建 VR/AR 交互、搭建 XR rig、或配置抓取/插槽/射线交互器时使用。