--- name: add-ui-feature description: "Add a new UI panel, control, or overlay to CLOiSim's HUD. Use when: adding a new button or panel to UIController, creating a new camera mode, adding an info overlay." --- # Add a New UI Feature Procedure for adding UI elements to CLOiSim's HUD using Unity UI Toolkit or extending camera controls. ## When to Use - Adding a new button, toggle, or panel to the main HUD - Creating a new info display or overlay - Adding a new camera view mode - Extending the following target list or model importer UI ## UI Architecture ``` UI (scene root) ├── Main Canvas (UIDocument + UIController) │ └── UI Toolkit visual tree (UXML) ├── InfoDisplay (legacy TextMeshPro overlay) └── FollowingTargetList ``` **Two UI systems in use:** - **UI Toolkit** — main HUD (`UIController.cs`): buttons, toggles, text fields, labels - **Legacy UGUI/TextMeshPro** — info overlay (`InfoDisplay.cs`): FPS counter, status text Do not mix UI Toolkit and UGUI in the same component. ## Procedure ### Option A: Add to Main HUD (UI Toolkit) #### 1. Add Element to UXML Edit the UXML document (referenced by the `UIDocument` component on the `Main Canvas` object). Add your element: ```xml ``` #### 2. Wire in UIController Edit `Assets/Scripts/UI/UIController.cs`: ```csharp // Add field private Button _buttonMyFeature = null; // In Start(), after other button wiring: _buttonMyFeature = _rootVisualElement.Q