You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: AGENTS.md
+20-3Lines changed: 20 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,7 @@
1
1
# GameLovers.UiService - AI Agent Guide
2
2
3
+
> **Companion files**: `CLAUDE.md` wraps this file for Claude Code — edit `AGENTS.md`, not `CLAUDE.md`. `docs/README.md` (and linked pages) is the user-facing documentation set.
4
+
3
5
## 1. Package Overview
4
6
-**Package**: `com.gamelovers.uiservice`
5
7
-**Unity**: 6000.0+
@@ -76,8 +78,14 @@ For user-facing docs, treat `docs/README.md` (and linked pages) as the primary d
-`Tests/EditMode/*` — unit tests (configs, sets, loaders, core service behavior). Owned by `GameLovers.UiService.Tests.asmdef` which is **editor-only** (`includePlatforms: ["Editor"]`).
82
+
-`Tests/PlayMode/*` — integration/performance/smoke tests and unit tests that require PlayMode (e.g. `DontDestroyOnLoad`). Owned by `GameLovers.UiService.Tests.PlayMode.asmdef` (runtime-compatible).
83
+
-`Tests/Helpers/*` — **shared test fixtures** consumed by both EditMode and PlayMode. Owned by `GameLovers.UiService.Tests.Helpers.asmdef` (runtime-compatible, gated by `defineConstraints: ["UNITY_INCLUDE_TESTS"]`). **MonoBehaviour-derived test presenters (e.g., `TestUiPresenter`, `TestDataUiPresenter`) MUST live here**, not under `Tests/EditMode/`. Placing a MonoBehaviour in the editor-only EditMode asmdef makes Unity reject `AddComponent<T>()` calls (silent `null` return + warning: `Can't add script behaviour '<name>' because it is an editor script`), which causes tests that create prefabs via `TestHelpers.CreateTestPresenterPrefab<T>` to run without ever attaching the presenter component.
84
+
-**Performance test pattern (`Measure.Method`)**: the body runs `WarmupCount + MeasurementCount` times. Stateful operations against `UiService` (Load/Unload/Open/Close) MUST use `.SetUp()` and/or `.CleanUp()` to reset per-iteration state — otherwise iterations 2+ hit the cache and log `The Ui <X> was already loaded` / `<X> is already open`, and the benchmark measures a no-op cache hit instead of the real operation. Correct shapes:
- Measuring **Unload**: `SetUp = Load; body = Unload;`
87
+
- See `Tests/PlayMode/Performance/PerformanceTests.cs` (`Perf_LoadUi_SinglePresenter`, `Perf_UnloadUi_SinglePresenter`) for the pattern.
88
+
-**`LogAssert.Expect` scope — asserts, does not silence**: `UnityEngine.TestTools.LogAssert.Expect(LogType.Warning, regex)` ensures a matching warning appears during the test (test fails if it doesn't) and prevents the warning from failing the test run for being "unexpected". It does **NOT** suppress the warning from `Editor.log` or the Unity Console — the log line is still emitted. Use it to **pin expected-warning contracts** (service behavior under test), not to reduce console noise. For the latter, restructure the test (see Performance test pattern above) or change the runtime log site — not `LogAssert`.
81
89
82
90
## 4. Important Behaviors / Gotchas
83
91
-**Instance address normalization**
@@ -107,6 +115,15 @@ For user-facing docs, treat `docs/README.md` (and linked pages) as the primary d
107
115
-**UI Toolkit visual tree timing and element recreation**
108
116
-`UIDocument.rootVisualElement` may not be ready when `OnInitialized()` is called on a presenter.
109
117
- UI Toolkit **recreates visual elements** when the presenter GameObject is deactivated/reactivated (close/reopen cycle), `AddVisualTreeAttachedListener(callback)` invokes on **each open** to handle element recreation.
118
+
-**UI Toolkit test `PanelSettings` creation — silence the theme warning**
119
+
- A runtime-created `PanelSettings` (no theme asset configured) makes Unity log `No Theme Style Sheet set to PanelSettings , UI will not render properly`**twice** per instantiation: once when assigned to `UIDocument.panelSettings`, and again when the hosting GameObject first goes `SetActive(true)`.
120
+
- Fix in test helpers: assign the theme **before** handing the panel to the document.
0 commit comments