Imported from YangLingCloud/HybridCLR_YooAsset_UniTask (
AGENTS.md). Install upstream withnpx skills add YangLingCloud/HybridCLR_YooAsset_UniTask. Copyright stays with the author.
AGENTS.md β com.yanglingyun.hyu v3.1.3
Project Overview
This repository is a pure Unity Package (UPM) root, not a Unity project.
- Package name:
com.yanglingyun.hyu - Version: 3.1.3
- Minimum Unity: 2022.3
- Domain: HybridCLR + YooAsset hot-update build toolchain
- Target platforms: Windows, Android, iOS
- License: MIT
This package provides an all-in-one editor build pipeline for Unity hot-update scenarios, integrating HybridCLR (C# hot-update), YooAsset (resource management), and UniTask (async programming).
Repository Structure
.
βββ package.json # UPM package definition (dependencies, samples)
βββ CHANGELOG.md # Changelog
βββ README.md / README_EN.md # Bilingual documentation (CN / EN)
βββ LICENSE # MIT
βββ README/ # Documentation assets (.png, .xmind, .pdf, .docx)
β
βββ Editor/ # Editor assembly: com.yanglingyun.hyu.Editor
β βββ HybridEditor.asmdef # Editor-only asmdef
β βββ BuildHelper.cs # AOT metadata check, DLL copy, APK build, link.xml supplement
β βββ HybridBuilderWindow.cs # UI Toolkit build window controller
β βββ HybridBuilderWindow.uxml # Window UI layout
β βββ HybridBuilderWindow.uss # Modern UI stylesheet (card layout, color scheme, button styles)
β βββ HybridBuilderSettings.cs # Build config ScriptableObject + HybridBuildOption enum
β βββ HybridBuildPipeViewerBase.cs # Build pipeline viewer base class
β βββ HybridBuildPipeViewerBase.uxml # Viewer UI layout (card-based design)
β βββ HybridScriptableBuildPipelineViewer.cs # SBP build pipeline viewer
β βββ HybridPaths.cs # Centralized path constants (AOT/HotUpdate DLL dirs, link.xml, manifests)
β βββ HybridRuntimeSettingsMigrator.cs # Auto-migrate legacy Packages JSON to structured list
β βββ SceneHelper.cs # Scene utilities
β βββ BuildPipelineTask/
β β βββ TaskBuildScript_SBP.cs # SBP custom build task (script packaging)
β βββ ScriptableBuildPipeline/
β βββ HybridScriptableBuildPipeline.cs # SBP pipeline impl
β βββ HybridScriptableBuildParameters.cs # SBP build parameters
β
βββ Runtime/ # Runtime assembly: com.yanglingyun.hyu.Runtime
β βββ com.yanglingyun.hyu.Runtime.asmdef
β βββ HybridRuntimeSettings.cs # Runtime config (HostServerIP, ReleaseBuildVersion, Packages)
β
βββ Samples~/ # Importable samples (UPM convention, not compiled)
βββ HotUpdateSample/ # Full hot-update sample
β βββ AOTScripts/ # AOT runtime scripts (AOTPublic.asmdef)
β βββ Editor/ # Sample editor tools (com.yanglingyun.hyu.Sample.Editor.asmdef)
β β βββ HybridSettingsImporter.cs # Auto/manual settings importer
β β βββ HybridCLRSettingsSnapshot.json # HybridCLR preset config snapshot
β βββ EventDefine/ # UniEvent event definitions (Battle/Patch/Scene/User)
β βββ HotUpdateAssets/ # Assets to be packaged (Prefabs/Scenes/Textures/Materials etc.)
β β βββ HotUpdateDll/ # Compiled hot-update DLL output directory
β β βββ PatchedAOTDLL/ # AOT supplementary metadata DLLs (.bytes)
β βββ HotUpdateScripts/ # Hot-update assembly (HotUpdate.asmdef)
β βββ PatchLogic/ # YooAsset patch download state machine (8 FSM nodes)
β βββ Resources/ # Built-in resources (PatchWindow prefab etc.)
β βββ Scripts/ # Main scene AOT scripts (GameManager, HybridLauncher)
β βββ Settings/ # Pre-configured ScriptableObject assets
β βββ ThirdParty/ # Lightweight dependencies (UniEvent/UniMachine/UniUtility)
βββ BuildTests/ # Build pipeline tests
βββ Editor/
βββ com.yanglingyun.hyu.Tests.Editor.asmdef
βββ HybridBuildPipelineTests.cs # NUnit EditMode tests
Assembly Structure
| Assembly | Type | Location | Description |
|---|---|---|---|
com.yanglingyun.hyu.Editor |
Editor | Editor/ |
Core editor build tools, Editor-only |
com.yanglingyun.hyu.Runtime |
Runtime | Runtime/ |
Runtime config types, all platforms |
com.yanglingyun.hyu.Sample.Editor |
Editor | Samples~/HotUpdateSample/Editor/ |
Sample editor tools |
com.yanglingyun.hyu.Tests.Editor |
Editor | Samples~/BuildTests/Editor/ |
Test assembly, requires UNITY_INCLUDE_TESTS |
AOTPublic |
Runtime | Samples~/HotUpdateSample/AOTScripts/ |
Sample AOT scripts |
HotUpdate |
Runtime | Samples~/HotUpdateSample/HotUpdateScripts/ |
Sample hot-update assembly |
Package Dependencies
Declared in package.json (resolved automatically by UPM):
| Package | Version | Purpose |
|---|---|---|
com.code-philosophy.hybridclr |
8.2.0 | HybridCLR hot-update core |
com.tuyoogame.yooasset |
2.3.9 | YooAsset resource management |
com.cysharp.unitask |
2.5.10 | UniTask async programming |
com.unity.scriptablebuildpipeline |
1.21.21 | SBP build pipeline |
com.unity.nuget.newtonsoft-json |
3.2.1 | JSON serialization |
Installation
"com.yanglingyun.hyu": "https://github.com/YangLingCloud/HybridCLR_YooAsset_UniTask.git"
No ?path= suffix needed β the repo root is the package root.
Editor Menus
Package Menus (HybridTool/)
| Menu Item | Function |
|---|---|
Check AOT Metadata |
Validate whether AOT metadata needs supplementation |
Build APK |
Build APK package |
Get Patched AOT Assembly List |
Get list of AOT assemblies requiring supplementation |
Generate AOT DLLs and Copy |
Generate AOT DLLs and copy to resource directory |
Generate Hot-Update DLLs and Copy |
Compile hot-update DLLs and copy to resource directory |
Supplement Prefab Dependencies |
Supplement prefab dependencies to link.xml |
Hybrid Builder |
Open UI Toolkit build window |
Sample Menus (HybridTool/Sample-HotUpdateSample/)
| Menu Item | Function |
|---|---|
Export HybridCLR Settings Snapshot |
Export current HybridCLR config snapshot |
Restore HybridCLR Settings from Snapshot |
Restore HybridCLR config from snapshot |
Normalize Collector Paths |
Normalize YooAsset collector paths |
Key Classes & Responsibilities
Editor/
-
BuildHelperβ Static utility class, core methods:GetBuildScenes()β Get build scene listEnsureAOTStripDirExists(aotDir)β Check AOT strip directory; if missing, prompt to triggerPrebuildCommand.GenerateAll()CheckAccessMissingMetadata()β Compare AOT vs hot-update DLLs to determine if APK rebuild is neededSupplementPrefabDependentmethods β Supplement link.xml (handles Missing Script safely, Set-based dedup)ProjectPathβ Project root directory (parent ofApplication.dataPath)
-
HybridBuilderSettingsβ Build config ScriptableObject, fields include:RuntimeSettingsβ Associated runtime configAssetPackagesβ Asset package name listScriptPackageNameβ Script package namePatchedAOTDLLFolder/HotUpdateDLLFolderβ DLL directory referencesReleaseBuildVersion/AssetBuildVersion/ScriptBuildVersionβ Version numbersbuildOutputPathβ Build output path (supports relative paths, resolved viaResolveBuildOutputPath())isClearBuildCache/isUseAssetDependDB/isUseSelfIncrementingVersionsβ Build optionsassetCompressOption/assetFileNameStyle/assetEncryptionClassNameβ YooAsset packaging optionsassetBuildinFileCopyOption/assetBuildinFileCopyParamsβ Built-in file copy optionshybridBuildOptionβ Hybrid build option (HybridBuildOptionenum: None/BuildAll/BuildAsset/BuildScript/BuildApplication)
-
HybridRuntimeSettings(Runtime/) β Runtime config ScriptableObject:HostServerIPβ Resource server addressReleaseBuildVersionβ Release versionPackagesβList<PackageVersion>(structured package name + version list, migrated from legacy JSON string viaHybridRuntimeSettingsMigrator)
-
HybridBuilderWindowβ UI Toolkit build window controller -
HybridBuildPipeViewerBaseβ Build pipeline viewer base class -
HybridScriptableBuildPipelineViewerβ SBP build pipeline viewer, distinguishes Asset/Script packaging -
TaskBuildScript_SBPβ SBP custom build task (script packaging flow) -
HybridScriptableBuildPipelineβ SBP pipeline implementation -
HybridScriptableBuildParametersβ SBP build parameter definition -
HybridPathsβ Centralized path/filename constants (eliminates magic strings across the codebase) -
HybridRuntimeSettingsMigratorβ One-time migration from legacyPackagesJSON string toList<PackageVersion> -
SceneHelperβ Scene utilities
Samples~/HotUpdateSample/Editor/
HybridSettingsImporterβ Auto-detects HybridCLR config on import, prompts snapshot restoreHybridCLRSettingsSnapshot.jsonβ Preset config snapshot (hotUpdateAssemblyDefinitions, patchAOTAssemblies, etc.)
Build Pipeline Architecture
Base Package Build (low frequency) Hot-Update Build (high frequency)
βββ PrebuildCommand.GenerateAll() βββ CompileDllCommand.CompileDllActiveBuildTarget()
β βββ Compile hot-update DLLs βββ Copy hot-update DLLs to HotUpdateAssets/
β βββ Il2CppDefGeneratorCommand βββ YooAsset asset packaging (Asset packages)
β βββ LinkGeneratorCommand βββ YooAsset script packaging (Script package, RawFile)
β βββ StripAOTDllCommand βββ Generate version info
βββ Copy AOT supplementary metadata
βββ Build APK
First-Build Prerequisite Chain
When the AOT strip directory does not exist, BuildHelper.EnsureAOTStripDirExists() automatically prompts and triggers PrebuildCommand.GenerateAll(), which executes the full chain: compile hot-update DLLs β generate IL2CPP definitions β generate link.xml β generate stripped AOT DLLs β generate bridge functions.
link.xml Defensive Handling
SupplementPrefabDependent automatically creates a valid XML document when HybridCLRData/Generated/link.xml is missing. It handles null components (Missing Script) safely and uses Set-based deduplication to prevent duplicate <type> nodes.
Build & Test
This repository is package source code. Build and test execution happens inside a host Unity project after importing the package and samples.
Tests
- Location:
Samples~/BuildTests/Editor/HybridBuildPipelineTests.cs - Type: NUnit EditMode tests
- Assembly:
com.yanglingyun.hyu.Tests.Editor(requiresUNITY_INCLUDE_TESTS) - Coverage:
- PathResolution β
ResolveBuildOutputPathrelative/absolute path resolution,GetBuildOutputPathversion subdirectory - VersionString β
GetCurrentVersionbuild format (three integers joined by underscore) and display format (with labels) - CopyDllEdgeCases β Empty path defense, source directory missing returns empty list
- PipelineTypeValidation β
HybridScriptableBuildPipelinerejects invalid parameter types - EndToEnd β
GenerateAllfirst-build artifact validation,CopyHotUpdateDll.bytes and manifest generation
- PathResolution β
- Tests marked
[Category("SlowTest")]execute actual build commands and take longer
Code Conventions
Language Rules
- Code identifiers: English
- UI text / dialogs / menu labels: English
- Code comments: Chinese (project convention)
- Documentation: Bilingual (README.md Chinese, README_EN.md English)
C# Style
- Allman brace style
- 4-space indentation
- Prefer explicit guard clauses and defensive checks
- Error logging:
Debug.unityLogger.LogError(tag, message) - ScriptableObject fields:
[SerializeField] private+ public property wrapper, setter callsEditorUtility.SetDirty(this) - XML doc comments use Chinese
<summary> CreateAssetMenuattribute for ScriptableObject creation menus
Known Filename Typos & Naming Inconsistencies
The following filenames have spelling inconsistencies. When modifying, keep .meta files in sync:
Samples~/HotUpdateSample/HotUpdateScripts/animate/β lowercase directory name (should be PascalCaseAnimate/)
Safety Rules
- NEVER let AOT assemblies reference the
HotUpdateasmdef (would cause hot-update DLLs to be processed by IL2CPP) - NEVER execute script packaging without generating AOT prerequisites first
- Sample-only logic must stay in
Samples~/HotUpdateSample/Editor/β do not promote to package-levelEditor/ HotUpdateasmdef must haveauto referencedisabled to prevent accidental reference byAssembly-CSharp- Pre-build must pass
BuildHelper.CheckAccessMissingMetadata()to verify hot-update code does not access stripped types
Agent Modification Guidelines
When Modifying Snapshot Import/Export Logic
- At runtime, prefer the imported sample local path:
Assets/Samples/com.yanglingyun.hyu/<version>/Hot Update Sample/Editor/ - Use package-internal path
Samples~/HotUpdateSample/Editor/only as development fallback - Note: sample display name is
Hot Update Sample(with spaces), directory name isHotUpdateSample(no spaces)
When Modifying Build Prerequisite Checks
- Must validate both AOT strip directory and hot-update DLL generation chain
- First-build bootstrap path should prefer
PrebuildCommand.GenerateAll() EnsureAOTStripDirExists()is the prerequisite check entry point
When Modifying link.xml Logic
- Must handle
HybridCLRData/Generated/link.xmlnot existing (auto-create) - Must handle null components (Missing Script) during safe traversal
- Use Set for type deduplication to prevent duplicate
<type>nodes
When Modifying Build Output Paths
HybridBuilderSettings.buildOutputPathsupports relative paths (relative to project root)- Resolved to absolute path via
ResolveBuildOutputPath() - Full output path obtained via
GetBuildOutputPath()(includes version subdirectory)
When Modifying YooAsset Collector Paths
- Sample Collector paths are stored as sample-relative paths
- After import, converted to absolute paths by
Normalize Collector Pathsmenu - Path normalization logic lives in
Samples~/HotUpdateSample/Editor/
When Adding New Editor Menus
- Package-level menus go under
HybridTool/ - Sample-level menus go under
HybridTool/Sample-HotUpdateSample/ - Menu labels must be in English
UI Design Guidelines
- NEVER use Emoji icons in any code, UI elements, labels, buttons, dialogs, menu items, or log messages
- Use plain text descriptions instead of emojis for better compatibility and professionalism
- Exception: Emojis are allowed ONLY in documentation files (README.md, CHANGELOG.md, comments) for visual enhancement
- This rule applies to: UI Toolkit labels, button text, dialog titles, menu items, log messages, error messages, C# string literals
Version Number Format
- Three-segment:
ReleaseBuildVersion_AssetBuildVersion_ScriptBuildVersion - Display format:
Release:{r} AssetPackage:{a} ScriptPackage:{s}
Version Management Rules
- Package version follows Semantic Versioning:
MAJOR.MINOR.PATCH(e.g., 3.1.1) - Default version increment: ALWAYS increment PATCH version (third number) for any changes
- MINOR version increment: Only when user explicitly requests it OR when adding significant new features
- MAJOR version increment: Only when user explicitly requests it OR when introducing breaking changes
- Examples:
- UI optimization: 3.1.0 β 3.1.1 (PATCH)
- Bug fixes: 3.1.1 β 3.1.2 (PATCH)
- New feature (user requested): 3.1.2 β 3.2.0 (MINOR)
- Breaking changes (user requested): 3.2.0 β 4.0.0 (MAJOR)
- When in doubt, use PATCH increment unless explicitly told otherwise
Known Assembly Definition Issues
HybridEditor.asmdefandcom.yanglingyun.hyu.Sample.Editor.asmdefboth reference a placeholder GUIDa1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6β this is a template/invalid reference that may cause assembly resolution warnings. Replace with actual GUID or remove if unused.
When Modifying README/ Documentation Assets
README/contains supplementary documentation files (.png diagrams, .xmind mind maps, .pdf, .docx)- These are NOT part of the UPM package distribution β consider adding to
.npmignoreif publishing to registry - Do not confuse with
README.md/README_EN.md(the actual package documentation)
