nccgs 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/agents/nccgs-accessibility-specialist.md +26 -0
- package/.claude/agents/nccgs-adversarial-reviewer.md +26 -0
- package/.claude/agents/nccgs-ai-programmer.md +26 -0
- package/.claude/agents/nccgs-analytics-engineer.md +26 -0
- package/.claude/agents/nccgs-art-direction-lead.md +26 -0
- package/.claude/agents/nccgs-audio-direction-lead.md +26 -0
- package/.claude/agents/nccgs-creative-director.md +26 -0
- package/.claude/agents/nccgs-documentation-manager.md +26 -0
- package/.claude/agents/nccgs-economy-designer.md +26 -0
- package/.claude/agents/nccgs-engine-programmer.md +26 -0
- package/.claude/agents/nccgs-game-design-lead.md +26 -0
- package/.claude/agents/nccgs-game-designer.md +26 -0
- package/.claude/agents/nccgs-gameplay-programmer.md +26 -0
- package/.claude/agents/nccgs-level-designer.md +26 -0
- package/.claude/agents/nccgs-live-ops-designer.md +26 -0
- package/.claude/agents/nccgs-localization-lead.md +26 -0
- package/.claude/agents/nccgs-narrative-lead.md +26 -0
- package/.claude/agents/nccgs-network-programmer.md +26 -0
- package/.claude/agents/nccgs-performance-analyst.md +26 -0
- package/.claude/agents/nccgs-producer.md +26 -0
- package/.claude/agents/nccgs-production-coordinator.md +23 -0
- package/.claude/agents/nccgs-programming-lead.md +26 -0
- package/.claude/agents/nccgs-prototyper.md +26 -0
- package/.claude/agents/nccgs-qa-engineer.md +26 -0
- package/.claude/agents/nccgs-qa-lead.md +26 -0
- package/.claude/agents/nccgs-release-engineer.md +26 -0
- package/.claude/agents/nccgs-release-lead.md +26 -0
- package/.claude/agents/nccgs-security-engineer.md +26 -0
- package/.claude/agents/nccgs-sound-designer.md +26 -0
- package/.claude/agents/nccgs-systems-designer.md +26 -0
- package/.claude/agents/nccgs-technical-architect.md +26 -0
- package/.claude/agents/nccgs-technical-artist.md +26 -0
- package/.claude/agents/nccgs-technical-director.md +26 -0
- package/.claude/agents/nccgs-tools-programmer.md +26 -0
- package/.claude/agents/nccgs-ui-programmer.md +26 -0
- package/.claude/agents/nccgs-unity-build-specialist.md +26 -0
- package/.claude/agents/nccgs-unity-content-specialist.md +26 -0
- package/.claude/agents/nccgs-unity-implementer.md +26 -0
- package/.claude/agents/nccgs-unity-rendering-specialist.md +26 -0
- package/.claude/agents/nccgs-unity-systems-specialist.md +26 -0
- package/.claude/agents/nccgs-unity-ui-specialist.md +26 -0
- package/.claude/agents/nccgs-ux-designer.md +26 -0
- package/.claude/agents/nccgs-verification-engineer.md +26 -0
- package/.claude/agents/nccgs-world-builder.md +26 -0
- package/.claude/agents/nccgs-writer.md +26 -0
- package/.claude/nccgs/THIRD_PARTY_NOTICES.md +13 -0
- package/.claude/nccgs/VERSION +1 -0
- package/.claude/nccgs/constitution.md +131 -0
- package/.claude/nccgs/hooks/agent-audit.mjs +10 -0
- package/.claude/nccgs/hooks/common.mjs +41 -0
- package/.claude/nccgs/hooks/post-compact.mjs +1 -0
- package/.claude/nccgs/hooks/pre-compact.mjs +8 -0
- package/.claude/nccgs/hooks/protect-git.mjs +22 -0
- package/.claude/nccgs/hooks/protect-write.mjs +17 -0
- package/.claude/nccgs/hooks/session-start.mjs +15 -0
- package/.claude/nccgs/hooks/session-stop.mjs +7 -0
- package/.claude/nccgs/protocols/agent-contract.md +34 -0
- package/.claude/nccgs/protocols/context-packets.md +13 -0
- package/.claude/nccgs/protocols/evidence.md +15 -0
- package/.claude/nccgs/protocols/model-routing.md +22 -0
- package/.claude/nccgs/protocols/orchestration.md +26 -0
- package/.claude/nccgs/protocols/unity-boundary.md +11 -0
- package/.claude/nccgs/settings.fragment.json +77 -0
- package/.claude/nccgs/studio.json +347 -0
- package/.claude/nccgs/tools/configure-models.mjs +39 -0
- package/.claude/nccgs/unity-skills-manifest.json +727 -0
- package/.claude/nccgs/workflow-catalog.json +317 -0
- package/.claude/rules/nccgs-canonical-docs.md +19 -0
- package/.claude/rules/nccgs-editor-tools.md +12 -0
- package/.claude/rules/nccgs-localization.md +12 -0
- package/.claude/rules/nccgs-networking.md +13 -0
- package/.claude/rules/nccgs-performance.md +14 -0
- package/.claude/rules/nccgs-rendering.md +16 -0
- package/.claude/rules/nccgs-security.md +13 -0
- package/.claude/rules/nccgs-tests.md +18 -0
- package/.claude/rules/nccgs-ui.md +14 -0
- package/.claude/rules/nccgs-unity-assets.md +21 -0
- package/.claude/rules/nccgs-unity-code.md +22 -0
- package/.claude/skills/accessibility-review/SKILL.md +14 -0
- package/.claude/skills/architecture-decision/SKILL.md +14 -0
- package/.claude/skills/asset-audit/SKILL.md +14 -0
- package/.claude/skills/audit/SKILL.md +16 -0
- package/.claude/skills/audit/references/dimensions.md +46 -0
- package/.claude/skills/balance-review/SKILL.md +14 -0
- package/.claude/skills/bug-triage/SKILL.md +14 -0
- package/.claude/skills/build-live-game/SKILL.md +317 -0
- package/.claude/skills/build-live-game/references/achievements.md +779 -0
- package/.claude/skills/build-live-game/references/apis.md +280 -0
- package/.claude/skills/build-live-game/references/authentication.md +437 -0
- package/.claude/skills/build-live-game/references/battlepass.md +860 -0
- package/.claude/skills/build-live-game/references/cloud-code.md +563 -0
- package/.claude/skills/build-live-game/references/cloud-save.md +474 -0
- package/.claude/skills/build-live-game/references/deployment.md +216 -0
- package/.claude/skills/build-live-game/references/player-account.md +813 -0
- package/.claude/skills/build-live-game/references/remote-config.md +96 -0
- package/.claude/skills/build-live-game/references/tooling.md +431 -0
- package/.claude/skills/closure/SKILL.md +14 -0
- package/.claude/skills/code-review/SKILL.md +14 -0
- package/.claude/skills/compatibility-review/SKILL.md +14 -0
- package/.claude/skills/context-pack/SKILL.md +14 -0
- package/.claude/skills/dependency-review/SKILL.md +14 -0
- package/.claude/skills/design/SKILL.md +20 -0
- package/.claude/skills/design-review/SKILL.md +14 -0
- package/.claude/skills/evidence-review/SKILL.md +14 -0
- package/.claude/skills/hotfix/SKILL.md +14 -0
- package/.claude/skills/implement-in-app-purchases/README.md +233 -0
- package/.claude/skills/implement-in-app-purchases/SKILL.md +158 -0
- package/.claude/skills/implement-in-app-purchases/references/api-notes.md +562 -0
- package/.claude/skills/implement-in-app-purchases/references/codeless-catalog.md +331 -0
- package/.claude/skills/implement-in-app-purchases/references/convert-adapty.md +268 -0
- package/.claude/skills/implement-in-app-purchases/references/convert-essentialkit.md +239 -0
- package/.claude/skills/implement-in-app-purchases/references/convert-revenuecat.md +275 -0
- package/.claude/skills/implement-in-app-purchases/references/convert-unipay.md +145 -0
- package/.claude/skills/implement-in-app-purchases/references/migration-v4-to-v5.md +204 -0
- package/.claude/skills/implement-in-app-purchases/references/path-add-iap-to-new-project.md +198 -0
- package/.claude/skills/implement-in-app-purchases/references/path-convert-native-google-billing.md +356 -0
- package/.claude/skills/implement-in-app-purchases/references/path-convert-native-storekit.md +446 -0
- package/.claude/skills/implement-in-app-purchases/references/path-implement-iap-d2c.md +680 -0
- package/.claude/skills/implement-in-app-purchases/references/platform-notes.md +204 -0
- package/.claude/skills/implement-in-app-purchases/references/pre-check.md +205 -0
- package/.claude/skills/incident-recovery/SKILL.md +14 -0
- package/.claude/skills/initialize-ai-navigation/SKILL.md +95 -0
- package/.claude/skills/initialize-ai-navigation/references/navigation-system.md +794 -0
- package/.claude/skills/levelplay-unity-integration/CHANGELOG.md +57 -0
- package/.claude/skills/levelplay-unity-integration/README.md +74 -0
- package/.claude/skills/levelplay-unity-integration/SKILL.md +1126 -0
- package/.claude/skills/levelplay-unity-integration/references/banner-api.md +920 -0
- package/.claude/skills/levelplay-unity-integration/references/best-practices.md +536 -0
- package/.claude/skills/levelplay-unity-integration/references/ilrd-api.md +337 -0
- package/.claude/skills/levelplay-unity-integration/references/initialization-api.md +630 -0
- package/.claude/skills/levelplay-unity-integration/references/interstitial-api.md +899 -0
- package/.claude/skills/levelplay-unity-integration/references/ios-setup.md +491 -0
- package/.claude/skills/levelplay-unity-integration/references/migration-sdk-9.md +666 -0
- package/.claude/skills/levelplay-unity-integration/references/privacy-settings.md +608 -0
- package/.claude/skills/levelplay-unity-integration/references/rewarded-api.md +902 -0
- package/.claude/skills/localization/SKILL.md +135 -0
- package/.claude/skills/localization/references/api-notes.md +76 -0
- package/.claude/skills/localization/resources/L10nBatchProcessor.cs +69 -0
- package/.claude/skills/localization/resources/LocalizedFontAsset.cs +18 -0
- package/.claude/skills/localize-game/SKILL.md +14 -0
- package/.claude/skills/migrate-project/SKILL.md +21 -0
- package/.claude/skills/migrate-project/references/procedure.md +63 -0
- package/.claude/skills/milestone-review/SKILL.md +14 -0
- package/.claude/skills/new-unity-project/SKILL.md +179 -0
- package/.claude/skills/optimize-audio/SKILL.md +199 -0
- package/.claude/skills/optimize-audio/resources/audio-import-api.md +146 -0
- package/.claude/skills/optimize-audio/resources/platform-settings.md +48 -0
- package/.claude/skills/optimize-text-mesh-pro/SKILL.md +182 -0
- package/.claude/skills/optimize-web/SKILL.md +393 -0
- package/.claude/skills/optimize-web/resources/WebOptimizer.cs +21 -0
- package/.claude/skills/optimize-web/resources/toktx-examples.sh +11 -0
- package/.claude/skills/performance-audit/SKILL.md +14 -0
- package/.claude/skills/physics-3d-collision/SKILL.md +442 -0
- package/.claude/skills/physics-3d-collision/references/troubleshooting.md +41 -0
- package/.claude/skills/physics-3d-collision/resources/CollisionDebugger.cs +33 -0
- package/.claude/skills/plan-feature/SKILL.md +14 -0
- package/.claude/skills/playtest/SKILL.md +14 -0
- package/.claude/skills/project-stage/SKILL.md +14 -0
- package/.claude/skills/prototype-feature/SKILL.md +14 -0
- package/.claude/skills/qa-plan/SKILL.md +14 -0
- package/.claude/skills/release/SKILL.md +18 -0
- package/.claude/skills/release-readiness/SKILL.md +14 -0
- package/.claude/skills/retrospective/SKILL.md +14 -0
- package/.claude/skills/review/SKILL.md +16 -0
- package/.claude/skills/security-audit/SKILL.md +14 -0
- package/.claude/skills/setup-multiplayer-services/SKILL.md +39 -0
- package/.claude/skills/setup-multiplayer-services/references/dgs-entrypoint.md +79 -0
- package/.claude/skills/setup-multiplayer-services/references/entrypoints.md +213 -0
- package/.claude/skills/setup-multiplayer-services/references/examples.md +33 -0
- package/.claude/skills/setup-multiplayer-services/references/implementation-fit.md +30 -0
- package/.claude/skills/setup-multiplayer-services/references/underlying-services.md +11 -0
- package/.claude/skills/setup-multiplayer-services/references/workflows-prerequisites.md +17 -0
- package/.claude/skills/setup-vivox-voice-chat/SKILL.md +118 -0
- package/.claude/skills/setup-vivox-voice-chat/evals/.env.example +6 -0
- package/.claude/skills/setup-vivox-voice-chat/evals/README.md +101 -0
- package/.claude/skills/setup-vivox-voice-chat/evals/promptfooconfig.yaml +32 -0
- package/.claude/skills/setup-vivox-voice-chat/evals/tests/init-and-login.yaml +76 -0
- package/.claude/skills/setup-vivox-voice-chat/evals/tests/text-chat.yaml +65 -0
- package/.claude/skills/setup-vivox-voice-chat/evals/tests/voice-channels.yaml +74 -0
- package/.claude/skills/setup-vivox-voice-chat/references/events-and-participants.md +79 -0
- package/.claude/skills/setup-vivox-voice-chat/references/init-and-login.md +92 -0
- package/.claude/skills/setup-vivox-voice-chat/references/text-chat.md +93 -0
- package/.claude/skills/setup-vivox-voice-chat/references/troubleshooting.md +47 -0
- package/.claude/skills/setup-vivox-voice-chat/references/voice-channels.md +90 -0
- package/.claude/skills/shader-graph-create-custom-node/SKILL.md +25 -0
- package/.claude/skills/shader-graph-create-custom-node/resources/all_hints.hlsl +182 -0
- package/.claude/skills/sprint-plan/SKILL.md +14 -0
- package/.claude/skills/sprite-editor/SKILL.md +66 -0
- package/.claude/skills/sprite-editor/references/api_reference.md +151 -0
- package/.claude/skills/sprite-editor/references/background.md +112 -0
- package/.claude/skills/sprite-editor/references/templates.md +72 -0
- package/.claude/skills/sprite-editor/scripts/AutomaticSliceTexture.cs +40 -0
- package/.claude/skills/sprite-editor/scripts/GenerateNewSpriteRects.cs +200 -0
- package/.claude/skills/sprite-editor/scripts/GetTextureSourceImageSize.cs +32 -0
- package/.claude/skills/sprite-editor/scripts/GetTextureToSlice.cs +55 -0
- package/.claude/skills/sprite-editor/scripts/GridSliceTexture.cs +40 -0
- package/.claude/skills/sprite-editor/scripts/IsometricSliceTexture.cs +141 -0
- package/.claude/skills/sprite-editor/scripts/README.md +134 -0
- package/.claude/skills/sprite-editor/scripts/SetPivotExample.cs +58 -0
- package/.claude/skills/sprite-editor/scripts/SpriteToPng.cs +88 -0
- package/.claude/skills/status/SKILL.md +16 -0
- package/.claude/skills/story-readiness/SKILL.md +14 -0
- package/.claude/skills/test/SKILL.md +16 -0
- package/.claude/skills/ui/SKILL.md +142 -0
- package/.claude/skills/ui-imgui/SKILL.md +186 -0
- package/.claude/skills/ui-imgui/references/gui-elements.md +156 -0
- package/.claude/skills/ui-imgui/references/templates.md +141 -0
- package/.claude/skills/ui-review/SKILL.md +14 -0
- package/.claude/skills/ui-ugui/SKILL.md +282 -0
- package/.claude/skills/ui-ugui/references/scrollview-setup.md +29 -0
- package/.claude/skills/ui-uitk/SKILL.md +235 -0
- package/.claude/skills/ui-uitk/references/common-issues.md +74 -0
- package/.claude/skills/ui-uitk/references/custom-elements.md +241 -0
- package/.claude/skills/ui-uitk/references/painter2d.md +282 -0
- package/.claude/skills/ui-uitk/references/pointermanipulator-guide.md +94 -0
- package/.claude/skills/ui-uitk/references/svg-icons.md +136 -0
- package/.claude/skills/ui-uitk/references/ui-runtime-binding.md +234 -0
- package/.claude/skills/ui-uitk/references/uss-guide.md +138 -0
- package/.claude/skills/unity-cli/CHANGELOG.md +233 -0
- package/.claude/skills/unity-cli/SECURITY.md +22 -0
- package/.claude/skills/unity-cli/SKILL.md +414 -0
- package/.claude/skills/unity-cli/references/auth-license-cloud.md +146 -0
- package/.claude/skills/unity-cli/references/build-run-test.md +349 -0
- package/.claude/skills/unity-cli/references/collaboration.md +472 -0
- package/.claude/skills/unity-cli/references/config-hub.md +103 -0
- package/.claude/skills/unity-cli/references/diagnostics-maintenance.md +326 -0
- package/.claude/skills/unity-cli/references/editors-install.md +327 -0
- package/.claude/skills/unity-cli/references/integration-advanced.md +472 -0
- package/.claude/skills/unity-cli/references/projects-templates.md +574 -0
- package/.claude/skills/unity-package-management/SKILL.md +304 -0
- package/.claude/skills/unity-package-management/references/select-packages.md +108 -0
- package/.claude/skills/urp-postprocessing/SKILL.md +188 -0
- package/.claude/skills/urp-postprocessing/references/code-templates.md +119 -0
- package/.claude/skills/urp-postprocessing/references/effect-reference.md +86 -0
- package/.claude/skills/validate-urp-render-graph-renderer-feature/SKILL.md +269 -0
- package/.claude/skills/work/SKILL.md +36 -0
- package/.claude/skills/work/references/classification.md +41 -0
- package/.claude/skills/work/references/closure.md +50 -0
- package/.claude/skills/work/references/feature-contracts.md +32 -0
- package/.claude/skills/work/references/verification.md +26 -0
- package/CLAUDE.md +6 -0
- package/LICENSE +21 -0
- package/README.md +162 -0
- package/THIRD_PARTY_NOTICES.md +23 -0
- package/UPGRADING.md +32 -0
- package/VERSION +1 -0
- package/docs/ARCHITECTURE.md +73 -0
- package/docs/HUONG-DAN-MIGRATE-VA-SU-DUNG.md +324 -0
- package/docs/MIGRATION-MATRIX.md +23 -0
- package/docs/PROJECT-POLICY.md +67 -0
- package/docs/WORKFLOWS.md +61 -0
- package/package-assets/setup-vivox-voice-chat-evals.gitignore +7 -0
- package/package.json +41 -0
- package/scaffold/.nccgs/bugs/.gitkeep +1 -0
- package/scaffold/.nccgs/closures/.gitkeep +1 -0
- package/scaffold/.nccgs/context/.gitkeep +1 -0
- package/scaffold/.nccgs/decisions/.gitkeep +1 -0
- package/scaffold/.nccgs/evidence/.gitkeep +1 -0
- package/scaffold/.nccgs/features/.gitkeep +1 -0
- package/scaffold/.nccgs/migrations/.gitkeep +1 -0
- package/scaffold/.nccgs/playtests/.gitkeep +1 -0
- package/scaffold/.nccgs/project.yaml +103 -0
- package/scaffold/.nccgs/requirements.yaml +10 -0
- package/scaffold/.nccgs/reviews/.gitkeep +1 -0
- package/scaffold/.nccgs/state.md +40 -0
- package/scaffold/.nccgs/templates/agent-handoff.md +25 -0
- package/scaffold/.nccgs/templates/architecture-decision.md +27 -0
- package/scaffold/.nccgs/templates/closure-record.md +51 -0
- package/scaffold/.nccgs/templates/context-packet.yaml +17 -0
- package/scaffold/.nccgs/templates/evidence-record.md +23 -0
- package/scaffold/.nccgs/templates/feature-contract.md +35 -0
- package/scaffold/.nccgs/templates/migration-plan.md +40 -0
- package/scaffold/.nccgs/templates/waiver.md +11 -0
- package/scripts/cli.mjs +56 -0
- package/scripts/install.mjs +267 -0
- package/scripts/sync-unity-skills.mjs +126 -0
- package/scripts/validate.mjs +205 -0
- package/tests/framework.test.mjs +121 -0
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
# Custom Visuals with Painter2D
|
|
2
|
+
|
|
3
|
+
## Table of Contents
|
|
4
|
+
|
|
5
|
+
- [The Pattern](#the-pattern)
|
|
6
|
+
- [Canvas-to-Painter2D Mapping](#canvas-to-painter2d-mapping)
|
|
7
|
+
- [Gradient Fills](#gradient-fills)
|
|
8
|
+
- [GradientElement — Full Example](#gradientelement--full-example)
|
|
9
|
+
- [Other Use Cases](#other-use-cases)
|
|
10
|
+
- [Rules](#rules)
|
|
11
|
+
|
|
12
|
+
USS cannot draw gradients, arbitrary shapes, arcs, or procedural patterns. For these, use the **Painter2D** API via the `generateVisualContent` callback.
|
|
13
|
+
|
|
14
|
+
Painter2D is modeled on the **HTML Canvas 2D** context — `BeginPath`, `MoveTo`, `LineTo`, `Arc`, `BezierCurveTo`, `Fill`, `Stroke` all map directly. Key differences from Canvas: text is drawn via `ctx.DrawText()` on the `MeshGenerationContext` (not on Painter2D itself), no `drawImage()` (use `fillTexture` or child elements with USS `background-image`), angles use `Angle.Degrees()` / `Angle.Turns()` structs, arc direction is an enum (`ArcDirection.Clockwise` / `.CounterClockwise`), and coordinates are local to the element's content rect.
|
|
15
|
+
|
|
16
|
+
**Drawing text:** Use `ctx.DrawText(string text, Vector2 pos, float fontSize, Color color, FontAsset font)` on the `MeshGenerationContext` directly. Pass `null` for `font` to use the element's USS font. This is useful when text must be positioned precisely within custom-drawn visuals — for simpler cases, child `Label` elements are easier.
|
|
17
|
+
|
|
18
|
+
## The Pattern
|
|
19
|
+
|
|
20
|
+
Every custom-drawn element: extend `VisualElement` directly (never `Label`, `Button`, etc. — Painter2D won't render correctly on those), subscribe to `generateVisualContent`, draw with `ctx.painter2D`, call `MarkDirtyRepaint()` when properties change. For animations, call `MarkDirtyRepaint()` every frame from an update loop.
|
|
21
|
+
|
|
22
|
+
```csharp
|
|
23
|
+
[UxmlElement]
|
|
24
|
+
public partial class MyCustomVisual : VisualElement
|
|
25
|
+
{
|
|
26
|
+
float m_Value = 0.5f;
|
|
27
|
+
|
|
28
|
+
[UxmlAttribute]
|
|
29
|
+
public float Value
|
|
30
|
+
{
|
|
31
|
+
get => m_Value;
|
|
32
|
+
set { m_Value = value; MarkDirtyRepaint(); }
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
public MyCustomVisual()
|
|
36
|
+
{
|
|
37
|
+
generateVisualContent += OnGenerateVisualContent;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
void OnGenerateVisualContent(MeshGenerationContext ctx)
|
|
41
|
+
{
|
|
42
|
+
float w = contentRect.width;
|
|
43
|
+
float h = contentRect.height;
|
|
44
|
+
if (w < 1f || h < 1f) return;
|
|
45
|
+
|
|
46
|
+
var painter = ctx.painter2D;
|
|
47
|
+
// ... drawing commands
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Name classes to match their purpose — `GradientCard`, `RadialProgress`, `WaveformDisplay`, etc.
|
|
53
|
+
|
|
54
|
+
## Canvas-to-Painter2D Mapping
|
|
55
|
+
|
|
56
|
+
| HTML Canvas 2D | Unity Painter2D |
|
|
57
|
+
|----------------|-----------------|
|
|
58
|
+
| `beginPath()` | `BeginPath()` |
|
|
59
|
+
| `moveTo(x, y)` | `MoveTo(new Vector2(x, y))` |
|
|
60
|
+
| `lineTo(x, y)` | `LineTo(new Vector2(x, y))` |
|
|
61
|
+
| `arc(cx, cy, r, start, end)` | `Arc(Vector2 center, float radius, Angle start, Angle end, ArcDirection dir)` |
|
|
62
|
+
| `arcTo(x1, y1, x2, y2, r)` | `ArcTo(Vector2 p1, Vector2 p2, float radius)` |
|
|
63
|
+
| `bezierCurveTo(...)` | `BezierCurveTo(Vector2 ctrl1, Vector2 ctrl2, Vector2 end)` |
|
|
64
|
+
| `quadraticCurveTo(...)` | `QuadraticCurveTo(Vector2 ctrl, Vector2 end)` |
|
|
65
|
+
| `closePath()` | `ClosePath()` |
|
|
66
|
+
| `rect(x, y, w, h)` | **No equivalent** — trace manually with `MoveTo`/`LineTo`/`ClosePath` |
|
|
67
|
+
| `fill()` | `Fill(FillRule rule = NonZero)` — use `OddEven` for holes/cutouts |
|
|
68
|
+
| `stroke()` | `Stroke()` |
|
|
69
|
+
| `lineWidth` | `lineWidth` |
|
|
70
|
+
| `strokeStyle` | `strokeColor` / `strokeGradient` / `strokeFillGradient` |
|
|
71
|
+
| `fillStyle` | `fillColor` / `fillGradient` / `fillTexture` |
|
|
72
|
+
| `lineCap` | `lineCap` — `LineCap.Butt` (default), `.Round`, `.Square` |
|
|
73
|
+
| `lineJoin` | `lineJoin` — `LineJoin.Miter` (default), `.Bevel`, `.Round` |
|
|
74
|
+
| `setLineDash([...])` | `SetDashPattern(float[])` |
|
|
75
|
+
| `lineDashOffset` | `dashOffset` |
|
|
76
|
+
|
|
77
|
+
Both `Fill()` and `Stroke()` can be called on the same path.
|
|
78
|
+
|
|
79
|
+
Angle helpers: `Angle.Degrees(float)`, `Angle.Radians(float)`, `Angle.Turns(float)`.
|
|
80
|
+
|
|
81
|
+
## Gradient Fills
|
|
82
|
+
|
|
83
|
+
USS has no `linear-gradient()` or `radial-gradient()`. Use `FillGradient`:
|
|
84
|
+
|
|
85
|
+
```csharp
|
|
86
|
+
// Linear — two-color shorthand
|
|
87
|
+
FillGradient.MakeLinearGradient(Color startColor, Color endColor, Vector2 start, Vector2 end, AddressMode mode)
|
|
88
|
+
// Linear — multi-stop via Gradient object
|
|
89
|
+
FillGradient.MakeLinearGradient(Gradient gradient, Vector2 start, Vector2 end, AddressMode mode)
|
|
90
|
+
|
|
91
|
+
// Radial — two-color shorthand
|
|
92
|
+
FillGradient.MakeRadialGradient(Color startColor, Color endColor, Vector2 center, float radius, Vector2 focus, AddressMode mode)
|
|
93
|
+
// Radial — multi-stop via Gradient object
|
|
94
|
+
FillGradient.MakeRadialGradient(Gradient gradient, Vector2 center, float radius, Vector2 focus, AddressMode mode)
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
`AddressMode`: `Clamp` (extend edge color), `Repeat` (tile), `Mirror` (reflect).
|
|
98
|
+
|
|
99
|
+
**Linear gradient direction** — controlled by start/end points:
|
|
100
|
+
|
|
101
|
+
| Direction | Start | End |
|
|
102
|
+
|-----------|-------|-----|
|
|
103
|
+
| Top → Bottom | `(0, 0)` | `(0, height)` |
|
|
104
|
+
| Left → Right | `(0, 0)` | `(width, 0)` |
|
|
105
|
+
| Diagonal | `(0, 0)` | `(width, height)` |
|
|
106
|
+
|
|
107
|
+
**Radial gradient** — set `focus` off-center to shift the bright spot.
|
|
108
|
+
|
|
109
|
+
## GradientElement — Full Example
|
|
110
|
+
|
|
111
|
+
A custom element rendering a linear gradient with rounded corners and optional border stroke. All properties exposed as UXML attributes.
|
|
112
|
+
|
|
113
|
+
```csharp
|
|
114
|
+
using UnityEngine;
|
|
115
|
+
using UnityEngine.UIElements;
|
|
116
|
+
|
|
117
|
+
[UxmlElement]
|
|
118
|
+
public partial class GradientElement : VisualElement
|
|
119
|
+
{
|
|
120
|
+
Color m_StartColor = new Color(0.13f, 0.59f, 0.95f);
|
|
121
|
+
Color m_EndColor = new Color(0.61f, 0.15f, 0.69f);
|
|
122
|
+
Color m_BorderColor = Color.white;
|
|
123
|
+
float m_BorderWidth = 2f;
|
|
124
|
+
float m_CornerRadius = 8f;
|
|
125
|
+
float m_GradientAlpha = 1f;
|
|
126
|
+
|
|
127
|
+
[UxmlAttribute]
|
|
128
|
+
public Color StartColor
|
|
129
|
+
{
|
|
130
|
+
get => m_StartColor;
|
|
131
|
+
set { m_StartColor = value; MarkDirtyRepaint(); }
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
[UxmlAttribute]
|
|
135
|
+
public Color EndColor
|
|
136
|
+
{
|
|
137
|
+
get => m_EndColor;
|
|
138
|
+
set { m_EndColor = value; MarkDirtyRepaint(); }
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
[UxmlAttribute]
|
|
142
|
+
public Color BorderColor
|
|
143
|
+
{
|
|
144
|
+
get => m_BorderColor;
|
|
145
|
+
set { m_BorderColor = value; MarkDirtyRepaint(); }
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
[UxmlAttribute]
|
|
149
|
+
public float BorderWidth
|
|
150
|
+
{
|
|
151
|
+
get => m_BorderWidth;
|
|
152
|
+
set { m_BorderWidth = value; MarkDirtyRepaint(); }
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
[UxmlAttribute]
|
|
156
|
+
public float CornerRadius
|
|
157
|
+
{
|
|
158
|
+
get => m_CornerRadius;
|
|
159
|
+
set { m_CornerRadius = value; MarkDirtyRepaint(); }
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
[UxmlAttribute]
|
|
163
|
+
public float GradientAlpha
|
|
164
|
+
{
|
|
165
|
+
get => m_GradientAlpha;
|
|
166
|
+
set { m_GradientAlpha = Mathf.Clamp01(value); MarkDirtyRepaint(); }
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
public GradientElement()
|
|
170
|
+
{
|
|
171
|
+
generateVisualContent += OnGenerateVisualContent;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
void OnGenerateVisualContent(MeshGenerationContext ctx)
|
|
175
|
+
{
|
|
176
|
+
float w = contentRect.width;
|
|
177
|
+
float h = contentRect.height;
|
|
178
|
+
if (w < 1f || h < 1f)
|
|
179
|
+
return;
|
|
180
|
+
|
|
181
|
+
DrawGradientBackground(
|
|
182
|
+
ctx.painter2D, w, h,
|
|
183
|
+
m_StartColor, m_EndColor, m_GradientAlpha,
|
|
184
|
+
m_CornerRadius,
|
|
185
|
+
m_BorderColor, m_BorderWidth);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
static void DrawGradientBackground(
|
|
189
|
+
Painter2D painter,
|
|
190
|
+
float width, float height,
|
|
191
|
+
Color startColor, Color endColor, float alpha,
|
|
192
|
+
float cornerRadius,
|
|
193
|
+
Color borderColor, float borderWidth)
|
|
194
|
+
{
|
|
195
|
+
float r = Mathf.Min(cornerRadius, Mathf.Min(width, height) * 0.5f);
|
|
196
|
+
|
|
197
|
+
var start = startColor;
|
|
198
|
+
var end = endColor;
|
|
199
|
+
start.a *= alpha;
|
|
200
|
+
end.a *= alpha;
|
|
201
|
+
|
|
202
|
+
painter.fillGradient = FillGradient.MakeLinearGradient(
|
|
203
|
+
BuildGradient(start, end),
|
|
204
|
+
new Vector2(0f, 0f),
|
|
205
|
+
new Vector2(0f, height),
|
|
206
|
+
AddressMode.Clamp);
|
|
207
|
+
|
|
208
|
+
painter.BeginPath();
|
|
209
|
+
TraceRoundedRect(painter, 0f, 0f, width, height, r);
|
|
210
|
+
painter.Fill();
|
|
211
|
+
|
|
212
|
+
if (borderWidth <= 0f)
|
|
213
|
+
return;
|
|
214
|
+
|
|
215
|
+
float half = borderWidth * 0.5f;
|
|
216
|
+
painter.strokeColor = borderColor;
|
|
217
|
+
painter.lineWidth = borderWidth;
|
|
218
|
+
painter.lineJoin = LineJoin.Round;
|
|
219
|
+
|
|
220
|
+
painter.BeginPath();
|
|
221
|
+
TraceRoundedRect(
|
|
222
|
+
painter, half, half,
|
|
223
|
+
width - borderWidth, height - borderWidth,
|
|
224
|
+
Mathf.Max(0f, r - half));
|
|
225
|
+
painter.Stroke();
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
static Gradient BuildGradient(Color start, Color end)
|
|
229
|
+
{
|
|
230
|
+
var gradient = new Gradient();
|
|
231
|
+
gradient.SetKeys(
|
|
232
|
+
new[] { new GradientColorKey(start, 0f), new GradientColorKey(end, 1f) },
|
|
233
|
+
new[] { new GradientAlphaKey(start.a, 0f), new GradientAlphaKey(end.a, 1f) });
|
|
234
|
+
return gradient;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
static void TraceRoundedRect(Painter2D p, float x, float y, float w, float h, float r)
|
|
238
|
+
{
|
|
239
|
+
p.MoveTo(new Vector2(x + r, y));
|
|
240
|
+
p.LineTo(new Vector2(x + w - r, y));
|
|
241
|
+
p.ArcTo(new Vector2(x + w, y), new Vector2(x + w, y + r), r);
|
|
242
|
+
p.LineTo(new Vector2(x + w, y + h - r));
|
|
243
|
+
p.ArcTo(new Vector2(x + w, y + h), new Vector2(x + w - r, y + h), r);
|
|
244
|
+
p.LineTo(new Vector2(x + r, y + h));
|
|
245
|
+
p.ArcTo(new Vector2(x, y + h), new Vector2(x, y + h - r), r);
|
|
246
|
+
p.LineTo(new Vector2(x, y + r));
|
|
247
|
+
p.ArcTo(new Vector2(x, y), new Vector2(x + r, y), r);
|
|
248
|
+
p.ClosePath();
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
### Usage in UXML
|
|
254
|
+
|
|
255
|
+
```uxml
|
|
256
|
+
<ui:UXML xmlns:ui="UnityEngine.UIElements">
|
|
257
|
+
<ui:Style src="Screen.uss" />
|
|
258
|
+
<GradientElement class="gradient-card"
|
|
259
|
+
start-color="#2196F3" end-color="#9C27B0"
|
|
260
|
+
gradient-alpha="0.9" corner-radius="12"
|
|
261
|
+
border-color="#FFFFFF" border-width="1">
|
|
262
|
+
<ui:Label text="Card Title" class="card-title" />
|
|
263
|
+
<ui:Label text="Description text goes here" class="card-desc" />
|
|
264
|
+
</GradientElement>
|
|
265
|
+
</ui:UXML>
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
The element participates in flexbox, accepts children, and can be styled with USS for sizing, padding, and margin. The gradient draws behind child content.
|
|
269
|
+
|
|
270
|
+
## Other Use Cases
|
|
271
|
+
|
|
272
|
+
Painter2D handles any visual USS cannot express — progress rings (`Arc()` with dynamic `endAngle`), custom shapes (polygons, stars, badges), charts (bar fills, pie segments, sparklines), decorative elements (wave patterns, bezier flourishes), and animated visuals (drive properties from C#, call `MarkDirtyRepaint()` each frame).
|
|
273
|
+
|
|
274
|
+
## Rules
|
|
275
|
+
|
|
276
|
+
- **Extend `VisualElement` directly** — never `Label`, `Button`, etc.
|
|
277
|
+
- **Guard zero dimensions** — `if (contentRect.width < 1f || contentRect.height < 1f) return;`
|
|
278
|
+
- **`BeginPath()` before every path** — omitting it causes silent failures
|
|
279
|
+
- **No `Rect()` method** — Painter2D has no rectangle convenience method. Trace rectangles manually with `MoveTo`/`LineTo`/`ClosePath` (see `TraceRoundedRect` in the gradient example)
|
|
280
|
+
- **Set style properties before `BeginPath()`** — `lineWidth`, `strokeColor`, `fillColor`, etc.
|
|
281
|
+
- **Never mutate the element inside `generateVisualContent`** — no style changes, no adding children, no `MarkDirtyRepaint()` from within the callback
|
|
282
|
+
- **`LineCap.Butt` for precise arc endpoints** — `Round` extends past the endpoint by half the line width
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
# UI Toolkit Manipulator Reference
|
|
2
|
+
|
|
3
|
+
Pointer Manipulators handle pointer interactions like drag and drop, click, hover, and gestures in Unity UI Toolkit.
|
|
4
|
+
|
|
5
|
+
## What is a Manipulator?
|
|
6
|
+
|
|
7
|
+
A `Manipulator` is an event handler class attached to `VisualElement`s to add interactive behavior. They encapsulate interaction logic and can be reused across multiple elements.
|
|
8
|
+
|
|
9
|
+
## Base Pattern
|
|
10
|
+
|
|
11
|
+
Pointer Manipulators inherit from `PointerManipulator` and override:
|
|
12
|
+
- `RegisterCallbacksOnTarget()` — Subscribe to events when attached
|
|
13
|
+
- `UnregisterCallbacksFromTarget()` — Unsubscribe when detached
|
|
14
|
+
|
|
15
|
+
Attach with: `element.AddManipulator(new YourManipulator())`
|
|
16
|
+
|
|
17
|
+
## Drag and Drop Approach
|
|
18
|
+
|
|
19
|
+
### Drag and Drop Code Design
|
|
20
|
+
1. **PointerDown** — Capture pointer, store pointer start position, store dragged element reference, mark as dragging, set to Aboslute positioning, and BringToFront
|
|
21
|
+
|
|
22
|
+
```csharp
|
|
23
|
+
_isDragging = true;
|
|
24
|
+
target.style.position = Position.Absolute;
|
|
25
|
+
target.BringToFront();
|
|
26
|
+
target.usageHints = UsageHints.DynamicTransform;
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
2. **PointerMove** — Update dragged element position relative to the pointer, check if pointer is over valid drop target. ALWAYS use the StyleTranslate API for drag and drop and updating element position unless otherwise specified.
|
|
30
|
+
|
|
31
|
+
Example of using StyleTranslate API:
|
|
32
|
+
```csharp
|
|
33
|
+
target.style.translate = new StyleTranslate(newWorldPosition);
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
3. **PointerUp** — If over drop target or find nearest overlapping target, execute drop logic (move element, trigger callback), release pointer
|
|
37
|
+
4. **PointerCaptureOut** — Finalize drop and raise event
|
|
38
|
+
|
|
39
|
+
### Drop Target Detection
|
|
40
|
+
Use `VisualElement.panel.Pick(position)` or check bounds with `worldBound.Contains(position)` to find elements under the pointer.
|
|
41
|
+
|
|
42
|
+
### Visual Feedback
|
|
43
|
+
Add/remove USS classes on drag start/end for hover states, drag shadows, or drop zone highlights:
|
|
44
|
+
```csharp
|
|
45
|
+
target.AddToClassList("dragging");
|
|
46
|
+
dropZone.AddToClassList("drop-zone-active");
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Best Practices
|
|
50
|
+
- Use USS classes for visual states instead of inline `element.style.*` properties
|
|
51
|
+
- Validate drop targets before executing drop logic
|
|
52
|
+
- Use `evt.StopPropagation();` to prevent dragged items from behaving like buttons or interacting unexpectedly
|
|
53
|
+
- To ensure dragged item is always on top use `BringToFront()`
|
|
54
|
+
- Decide the `pickingMode` for the dragged item to ensure the slot underneath is detected and revert to proper state after dropping
|
|
55
|
+
|
|
56
|
+
## Common Enhancements
|
|
57
|
+
|
|
58
|
+
- **Constrain to bounds** — Clamp position to parent or screen bounds
|
|
59
|
+
- **StyleTranslation API** - Use `target.style.translate = new StyleTranslate(newWorldPosition)` to avoid style pass updates
|
|
60
|
+
- **Performance** - Use Usage Hints and `UsageHints.DynamicTransform;` for better performance
|
|
61
|
+
- **Drop validation** — Check if drop target accepts this element type
|
|
62
|
+
- **Revert on invalid drop** — Animate back to start position if dropped outside valid zone
|
|
63
|
+
|
|
64
|
+
## Inventory and Crafting Systems
|
|
65
|
+
|
|
66
|
+
When users request inventory or crafting systems, first determine requirements:
|
|
67
|
+
|
|
68
|
+
### Ask Users First
|
|
69
|
+
- "Should players be able to drag and drop items between slots?"
|
|
70
|
+
- "Should items snap to grid positions or specific equipment slots?"
|
|
71
|
+
- "Do items stack? Do they have quantities?"
|
|
72
|
+
|
|
73
|
+
If drag-and-drop is NOT needed, create static visual layout only (UXML/USS).
|
|
74
|
+
|
|
75
|
+
### When to Use Drag-Drop
|
|
76
|
+
|
|
77
|
+
**Inventory systems need drag-drop when:**
|
|
78
|
+
- Players move items between slots (inventory, equipment, hotbar)
|
|
79
|
+
- Items can be equipped to specific slots (head, chest, weapon)
|
|
80
|
+
- Players organize or sort their inventory
|
|
81
|
+
|
|
82
|
+
**Crafting systems need drag-drop when:**
|
|
83
|
+
- Players place ingredients into crafting slots
|
|
84
|
+
- Players combine items by dragging them together
|
|
85
|
+
- Recipe slots require specific item types
|
|
86
|
+
|
|
87
|
+
**Implementation Checklist**
|
|
88
|
+
When implementing drag-drop for inventory/crafting:
|
|
89
|
+
- Created manipulator and callback methods for draggable UI element
|
|
90
|
+
- Created UI element or slots as a drop zone
|
|
91
|
+
- Added USS classes for dragging and drop states
|
|
92
|
+
- Stored item data separately from visual elements (use data binding or C# dictionaries)
|
|
93
|
+
- Validated drop targets before executing drop
|
|
94
|
+
- Added visual feedback: drag shadows, slot highlighting, hover states
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
# SVG Icon Generation (Unity 6.3+)
|
|
2
|
+
|
|
3
|
+
## Table of Contents
|
|
4
|
+
|
|
5
|
+
- [When to Use SVG](#when-to-use-svg)
|
|
6
|
+
- [Priority Order](#priority-order)
|
|
7
|
+
- [SVG Format](#svg-format)
|
|
8
|
+
- [Common Icon Examples](#common-icon-examples)
|
|
9
|
+
- [Usage in Unity](#usage-in-unity)
|
|
10
|
+
- [Tips](#tips)
|
|
11
|
+
|
|
12
|
+
## When to Use SVG
|
|
13
|
+
|
|
14
|
+
**Prefer SVG for:**
|
|
15
|
+
- Simple icons (arrows, chevrons, checkmarks)
|
|
16
|
+
- Geometric shapes
|
|
17
|
+
- UI symbols (close, menu, settings)
|
|
18
|
+
- Any icon that can be drawn with paths
|
|
19
|
+
|
|
20
|
+
**Use image generators for:**
|
|
21
|
+
- Complex illustrations
|
|
22
|
+
- Photorealistic content
|
|
23
|
+
- Detailed artwork
|
|
24
|
+
- Gradients with many stops
|
|
25
|
+
|
|
26
|
+
## Priority Order
|
|
27
|
+
|
|
28
|
+
1. **Reuse existing project icons** — always search first
|
|
29
|
+
2. **Generate SVG** — fast, resolution-independent, low cost
|
|
30
|
+
3. **Image generators** — last resort, slower and higher cost
|
|
31
|
+
|
|
32
|
+
## SVG Format
|
|
33
|
+
|
|
34
|
+
Unity imports SVG as VectorImage assets. Use standard SVG markup:
|
|
35
|
+
|
|
36
|
+
```svg
|
|
37
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
|
|
38
|
+
<path d="..." stroke="currentColor" stroke-width="2" fill="none"/>
|
|
39
|
+
</svg>
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Common Icon Examples
|
|
43
|
+
|
|
44
|
+
### Arrow Right
|
|
45
|
+
```svg
|
|
46
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
|
|
47
|
+
<path d="M8 4l8 8-8 8" stroke="currentColor" stroke-width="2" fill="none" stroke-linecap="round" stroke-linejoin="round"/>
|
|
48
|
+
</svg>
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### Arrow Left
|
|
52
|
+
```svg
|
|
53
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
|
|
54
|
+
<path d="M16 4l-8 8 8 8" stroke="currentColor" stroke-width="2" fill="none" stroke-linecap="round" stroke-linejoin="round"/>
|
|
55
|
+
</svg>
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Chevron Down
|
|
59
|
+
```svg
|
|
60
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
|
|
61
|
+
<path d="M4 8l8 8 8-8" stroke="currentColor" stroke-width="2" fill="none" stroke-linecap="round" stroke-linejoin="round"/>
|
|
62
|
+
</svg>
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Checkmark
|
|
66
|
+
```svg
|
|
67
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
|
|
68
|
+
<path d="M4 12l6 6L20 6" stroke="currentColor" stroke-width="2" fill="none" stroke-linecap="round" stroke-linejoin="round"/>
|
|
69
|
+
</svg>
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Close (X)
|
|
73
|
+
```svg
|
|
74
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
|
|
75
|
+
<path d="M6 6l12 12M18 6L6 18" stroke="currentColor" stroke-width="2" fill="none" stroke-linecap="round"/>
|
|
76
|
+
</svg>
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### Plus
|
|
80
|
+
```svg
|
|
81
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
|
|
82
|
+
<path d="M12 4v16M4 12h16" stroke="currentColor" stroke-width="2" fill="none" stroke-linecap="round"/>
|
|
83
|
+
</svg>
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Minus
|
|
87
|
+
```svg
|
|
88
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
|
|
89
|
+
<path d="M4 12h16" stroke="currentColor" stroke-width="2" fill="none" stroke-linecap="round"/>
|
|
90
|
+
</svg>
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Menu (Hamburger)
|
|
94
|
+
```svg
|
|
95
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
|
|
96
|
+
<path d="M4 6h16M4 12h16M4 18h16" stroke="currentColor" stroke-width="2" fill="none" stroke-linecap="round"/>
|
|
97
|
+
</svg>
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### Settings (Gear)
|
|
101
|
+
```svg
|
|
102
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
|
|
103
|
+
<circle cx="12" cy="12" r="3" stroke="currentColor" stroke-width="2" fill="none"/>
|
|
104
|
+
<path d="M12 1v4M12 19v4M4.22 4.22l2.83 2.83M16.95 16.95l2.83 2.83M1 12h4M19 12h4M4.22 19.78l2.83-2.83M16.95 7.05l2.83-2.83" stroke="currentColor" stroke-width="2" fill="none" stroke-linecap="round"/>
|
|
105
|
+
</svg>
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### Search (Magnifying Glass)
|
|
109
|
+
```svg
|
|
110
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
|
|
111
|
+
<circle cx="10" cy="10" r="6" stroke="currentColor" stroke-width="2" fill="none"/>
|
|
112
|
+
<path d="M14.5 14.5L20 20" stroke="currentColor" stroke-width="2" fill="none" stroke-linecap="round"/>
|
|
113
|
+
</svg>
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## Usage in Unity
|
|
117
|
+
|
|
118
|
+
1. Save SVG file to project (e.g., `Assets/UI/Icons/arrow-right.svg`)
|
|
119
|
+
2. Unity auto-imports as VectorImage
|
|
120
|
+
3. Set "Generated Asset Type" to "UI Toolkit Vector Image" in Inspector
|
|
121
|
+
4. Reference in USS:
|
|
122
|
+
|
|
123
|
+
```uss
|
|
124
|
+
.icon-arrow {
|
|
125
|
+
background-image: url("project://database/Assets/UI/Icons/arrow-right.svg");
|
|
126
|
+
width: 24px;
|
|
127
|
+
height: 24px;
|
|
128
|
+
}
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## Tips
|
|
132
|
+
|
|
133
|
+
- Use `viewBox="0 0 24 24"` for consistent sizing
|
|
134
|
+
- Use `stroke="currentColor"` for tintable icons
|
|
135
|
+
- Use `fill="none"` for outline-style icons
|
|
136
|
+
- Keep paths simple — complex SVGs may not render correctly
|