|
| 1 | +# Unity-SerializeReferenceExtensions — AGENTS.md |
| 2 | + |
| 3 | +## Project overview |
| 4 | +This repository provides editor tooling for Unity's [SerializeReference], including `SubclassSelector` |
| 5 | +to pick concrete implementations of interfaces / abstract types in the Inspector. |
| 6 | + |
| 7 | +Primary risk area: type discovery & filtering (what types appear in the selector). |
| 8 | + |
| 9 | +## Repository layout |
| 10 | +- Repository URL: `https://github.com/mackysoft/Unity-SerializeReferenceExtensions` |
| 11 | +- Package source: `Assets/MackySoft/MackySoft.SerializeReferenceExtensions` |
| 12 | +- Editor code: `.../Editor/**` |
| 13 | +- Tests: `.../Tests/**` |
| 14 | + |
| 15 | +## Unity compatibility (critical) |
| 16 | +- Minimum supported Unity: 2021.3 (baseline for development/testing). |
| 17 | +- Unity 2023.2+ has enhanced generic type support (variance, etc.). Changes must not break 2021.3 behavior and guarded by `UNITY_2023_2_OR_NEWER`. |
| 18 | + |
| 19 | +## CI (GitHub Actions) |
| 20 | +I use GameCI `unity-test-runner`. |
| 21 | +- Always run EditMode tests. |
| 22 | +- Run a Unity matrix that includes: |
| 23 | + - 2021.3.x (minimum baseline) |
| 24 | + - 2023.2+ (generic/variance feature gate) |
| 25 | + |
| 26 | +## How to run tests locally |
| 27 | +### EditMode |
| 28 | +Run Unity in batchmode: |
| 29 | +``` |
| 30 | +PROJECT_ROOT="$(pwd)" |
| 31 | +RESULT_XML="$PROJECT_ROOT/TestResults/editmode.xml" |
| 32 | +
|
| 33 | +mkdir -p "$(dirname "$RESULT_XML")" |
| 34 | +
|
| 35 | +"<UNITY_EXE>" -batchmode -nographics -quit \ |
| 36 | + -projectPath "$PROJECT_ROOT" \ |
| 37 | + -runTests -testPlatform editmode \ |
| 38 | + -testResults "$RESULT_XML" |
| 39 | +``` |
| 40 | + |
| 41 | +## Architecture guardrails |
| 42 | +- Runtime surface area should remain minimal (mainly attributes / data structures). |
| 43 | +- Editor implementation (PropertyDrawer/UI/type search) must stay under `Editor/`. |
| 44 | +- Avoid introducing UnityEditor references into Runtime assemblies. |
| 45 | + |
| 46 | +## Coding conventions |
| 47 | +- Prefer `UnityEditor.TypeCache` for type discovery. Avoid full AppDomain scans unless necessary. |
| 48 | +- Keep allocations low in IMGUI paths (e.g., `OnGUI`). |
| 49 | +- Keep public API stable; if changing type filtering behavior, add/adjust tests. |
| 50 | +- As a general rule, you should follow the restrictions on SerializeReference in Unity's official documentation. |
| 51 | + - https://docs.unity3d.com/ScriptReference/SerializeReference.html |
0 commit comments