|
| 1 | +# AGENTS.md |
| 2 | + |
| 3 | +This repository is a Unity sample project for building a desktop-OS-style window UI using only UGUI. |
| 4 | + |
| 5 | +## Project Basics |
| 6 | + |
| 7 | +- Unity version: `6000.2.6f2` or newer. |
| 8 | +- Main sample scene: `Assets/UGUIWindowSample/Scenes/UGUIWindowSampleScene.unity`. |
| 9 | +- Core code lives under `Assets/UGUIWindowSample/Scripts/`. |
| 10 | +- Window prefabs are loaded by convention from `Assets/Resources/Windows/{ClassName}.prefab`. |
| 11 | +- Public-facing documentation starts at `README.md` and `docs/Manual.md`. |
| 12 | + |
| 13 | +## Important Docs |
| 14 | + |
| 15 | +Read these before changing behavior: |
| 16 | + |
| 17 | +- `docs/manual/02-concepts.md` for architecture, pooling, z-order, and DPI. |
| 18 | +- `docs/manual/03-creating-windows.md` for creating custom windows and prefab naming. |
| 19 | +- `docs/manual/06-events-lifecycle.md` for open, close, focus, and minimize events. |
| 20 | +- `docs/manual/07-samples.md` for the desktop sample scene. |
| 21 | +- `docs/manual/08-api-reference.md` for public APIs. |
| 22 | +- `docs/ClassDiagram.md` and `docs/class-diagram/*.md` for class relationships. |
| 23 | + |
| 24 | +## Architecture Notes |
| 25 | + |
| 26 | +- `UGUIWindowManager` is the singleton entry point for window creation, pooling, z-order, DPI scaling, and ESC handling. |
| 27 | +- `UGUIWindow` is the controller for each window. It owns the window mode and exposes: |
| 28 | + - `OnOpenWindow` |
| 29 | + - `OnCloseWindow` |
| 30 | + - `OnFocusWindow` |
| 31 | + - `OnMinimizeWindow` |
| 32 | +- `UGUIWindowView` owns visual state such as header, border, buttons, fade, and maximized/restored layout. |
| 33 | +- `UGUIWindowState` stores position, size, anchors, and flags for restore behavior. |
| 34 | +- The sample desktop layer is in `Assets/UGUIWindowSample/Scripts/Sample/`. |
| 35 | + |
| 36 | +## Implementation Guidelines |
| 37 | + |
| 38 | +- Prefer existing patterns over new abstractions. |
| 39 | +- Keep base window-system changes small and reusable. |
| 40 | +- Put demo-only behavior in the `Sample` folder unless the feature belongs to the framework. |
| 41 | +- When overriding `UGUIWindow.Awake` or `UGUIWindow.OnEnable`, call `base` first. |
| 42 | +- Use `UGUIWindowLog` for project logs instead of raw `Debug.Log` in framework code. |
| 43 | +- Preserve object pooling behavior unless the task explicitly changes it. |
| 44 | +- For features that observe window state, prefer subscribing to existing window events instead of polling. |
| 45 | +- Avoid editing Unity prefab or scene YAML by hand unless the change is small, deliberate, and easy to verify. |
| 46 | + |
| 47 | +## Unity Asset Guidelines |
| 48 | + |
| 49 | +- Keep `.meta` files with their assets. |
| 50 | +- Use forward slashes in Unity asset paths. |
| 51 | +- Do not rename prefab/class pairs casually; window loading depends on class-name-to-prefab-name matching. |
| 52 | +- If creating a new window class, add the matching prefab under `Assets/Resources/Windows/`. |
| 53 | +- If changing serialized fields, consider whether existing prefabs need their references assigned in Unity. |
| 54 | + |
| 55 | +## Testing And Verification |
| 56 | + |
| 57 | +- If Unity MCP/editor tools are available, use them to check compilation after C# changes. |
| 58 | +- At minimum, inspect changed C# files and run repository searches for broken references. |
| 59 | +- For UI work, verify the sample scene still covers: |
| 60 | + - create/open |
| 61 | + - focus/z-order |
| 62 | + - minimize/restore |
| 63 | + - close/pooling |
| 64 | + - DPI changes |
| 65 | + |
| 66 | +## Current Sample Flow |
| 67 | + |
| 68 | +- `UGUIDesktop` gathers child `UGUIIcon` components and spawns a few demo windows on `Start`. |
| 69 | +- `UGUIIcon` opens a window by resolving `UGUIWindow.{targetClassName}` on double click. |
| 70 | +- `UGUIMenu` opens the settings window and can quit the app. |
| 71 | +- `UGUIApplicationSetting` applies resolution, fullscreen mode, framerate, and DPI changes. |
| 72 | + |
0 commit comments