Communitygithub.com

unity-technologies/initialize-ai-navigation

設定並配置 Unity AI 導航系統 — NavMesh 表面、NavMesh 代理、障礙物、連結、修飾器、區域與成本。用於建立可行走導航網格、加入尋路代理、設定巡邏路線、配置障礙物迴避與雕刻、透過連結連接不同 NavMesh、將導航與動畫結合,或排除導航問題。

initialize-ai-navigation 是什麼?

這個技能為 Unity 開發者提供完整的 AI 導航系統設定引導,涵蓋 NavMeshSurface、NavMeshAgent、NavMeshObstacle、NavMeshLink、NavMeshModifier 等元件的建立與配置。使用者可以透過自然的語言指令,例如「加入導航」、「讓角色尋路」、「避開障礙物」、「連接兩個區域」等,獲得對應的程式碼與工作流程指引。該技能支援 Unity Editor 環境,並特別強調在通過 `eval` 執行 C# 程式碼時,必須使用完整型別名稱,因為 `eval` 不接受 `using` 指令。此外,技能包含了套件安裝檢查、現有組件盤點、資訊收集、逐步設定、驗證與最終確認等階段,確保 NavMesh 烘焙正確、代理行為符合預期,並避免元件衝突,大幅提升開發效率。

相容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/unity-technologies/skills/tree/main/skills/initialize-ai-navigation

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

判斷使用者的需求,並引導他們完成導航設定。如需擴充的元件細節、API 筆記、程式碼範例及疑難排解,請參閱 navigation-system.md。

傳遞 C# 給 eval

eval 編譯的是陳述式區塊,而非檔案。這會導致兩個後果,且都會產生編譯錯誤而非警告:

  • 不能使用 using 指示詞。 編譯器會將 using UnityEngine; 解讀為資源釋放陳述式而拒絕它(CS0210)。
  • 型別必須使用完整名稱。 單純使用 AssetDatabase 或 Volume 無法解析(CS0246 / CS0103),而單純使用 Object 會與 object 產生歧義(CS0104)。

如果下方程式碼片段是以檔案形式撰寫(為方便閱讀而加入 using,或因為需要儲存到專案中),請在傳遞給 eval 之前將型別改為完整名稱。

路由邏輯

使用者說法解讀
「加入導航」/「設定 nav」完整設定:NavMeshSurface + 烘焙 + NavMeshAgent
「讓這個角色導航」加入 NavMeshAgent,確保 NavMesh 存在
「加入尋路」NavMeshAgent + 移動腳本
「代理不會移動」/「找不到路徑」疑難排解 — 請參閱參考中的疑難排解決策樹
「避開障礙物」啟用雕刻或迴避的 NavMeshObstacle
「連接兩個區域」/「跳過去」區域之間的 NavMeshLink
「在點之間巡邏」NavMeshAgent + 巡邏腳本
「點擊移動」NavMeshAgent + 射線點擊移動腳本
「導航時讓角色動畫化」將 Animator 與 NavMeshAgent 結合
「不同代理大小」在 Navigation 視窗中配置代理類型
「區域和成本」/「限制區域」NavMesh 區域類型、修飾器和代理區域遮罩

工作流程

0. 套件安裝檢查

在執行任何操作之前,請先確認 com.unity.ai.navigation 已安裝。如果缺少此套件,請將其加入 Packages/manifest.json 的 dependencies 中 — Unity 會在編輯器下次取得焦點時自動解析,這個過程不需要編輯器連線:

"com.unity.ai.navigation": "<current 2.x version>"

不要自行編造版本字串。請從 Unity 註冊表讀取目前版本 — https://packages.unity.com/com.unity.ai.navigation 會列出所有已發布的版本 — 或者複製此 manifest 中相鄰 Unity 套件已使用的版本。不存在的版本會導致 Unity 無聲地解析失敗,因此錯誤的猜測就像什麼事都沒發生一樣。

只有在確認已安裝後才能繼續。如果您有可執行的編輯器來執行 C#,請參閱 navigation-system.md 中的 Client.Add 對應方法。

1. 預先檢查:評估目前的導航設定

在進行更改之前,先檢查已存在的內容:

  1. 找出現有的導航元件。如果編輯器已連線,請查詢即時場景中的 NavMeshSurface、NavMeshAgent、NavMeshObstacle、NavMeshLink 與 NavMeshModifier — 請參閱 unity-cli 技能以驅動執行中的編輯器。如果沒有連線,請搜尋場景和預製件檔案中的這些元件名稱。
  2. 透過 Window > AI > Navigation > Agents 索引標籤 檢查已配置的代理類型。
  3. 在提出變更之前,摘要列出所有偵測到的導航元件。

2. 收集遺漏的資訊

在建立元件之前,請確保使用者已指定:可行走表面、代理類型/大小、代理行為、障礙物、連結以及區域/成本需求。如有任何不清楚的地方,請提出詢問。詳細資訊收集檢查清單請參閱參考文件。

3. 規劃與執行

請依照下列一般順序進行。每個元件的逐步詳細說明請參閱參考文件中的元件設定指南:

  1. NavMesh Surface — 建立可行走網格(烘焙它)
  2. NavMesh Agent — 加入尋路角色
  3. NavMesh Obstacle — 加入動態障礙物
  4. NavMesh Link — 連接不相連的 NavMesh 區域
  5. NavMesh Modifier / Modifier Volume — 微調區域類型
  6. 腳本 — 移動、巡邏、點擊移動、動畫結合(請參閱參考文件中的常見食譜)

4. 驗證

設定完成後,請確認:

  • NavMesh 已烘焙且可見(藍色疊層)
  • NavMeshSurface 的代理類型與 NavMeshAgent 的代理類型相符
  • 代理有通往目的地的有效路徑
  • 障礙物正確雕刻或阻擋
  • 連結兩端都已連接且「已啟用」為開啟
  • 區域遮罩允許預期的移動
  • 沒有衝突的元件(請參閱參考文件中的混合元件指南)
  • 如果將 Rigidbody 與 NavMeshAgent 一起使用,請啟用 Is Kinematic

5. 最終確認

摘要列出已建立或更改的內容:

  • NavMesh Surface:隸屬的 GameObject、代理類型、幾何模式、烘焙狀態
  • NavMesh Agent:隸屬的 GameObject、速度、停止距離、區域遮罩
  • NavMesh Obstacle:隸屬的 GameObject、形狀、雕刻開/關
  • NavMesh Link:起點/終點、雙向、區域類型
  • 腳本:附加到哪些 GameObject 的哪些腳本
  • 任何需要手動執行的步驟(調整路徑點、場景變更後重新烘焙等)

Individual skills in this repo

This repo contains 9 individual skills — each has its own dedicated page.

unity-technologies/2d-pixel-perfect

Sets up, diagnoses, and fixes pixel perfect 2D rendering in Unity projects. Use when working on any retro-style or pixel art 2D game.

unity-technologies/audio-setup-mixers

Scans the scene and audio assets to appropriately route Audio Sources into existing Audio Mixer Groups, classifying each source by what it plays. Use when the user asks about cleaning up mixer assignments, routing audio through a mixer, or which group a sound belongs in. Creating mixers and groups, and setting volumes, are not automated — the skill inventories what exists and asks the user to add anything missing.

unity-technologies/build-live-game

Build and operate a live game using Unity Services. Use when the user needs to implement, connect, or debug backend-driven features — battle passes, achievements, player progression, cloud saves, leaderboards, matchmaking, virtual economies, server-authoritative logic, anti-cheat, player accounts and authentication, remote configuration, feature flags, A/B testing, analytics, or cloud resource deployment. Triggers on live-ops, live service, backend, server authority, cloud code, cloud save, remote config, player data, retention, monetization loop, season pass, ranking, multiplayer sessions, lobbies, or any Unity Services integration.

unity-technologies/generate-editor-search-query

Generates Unity Search / Quick Search queries and opens the Unity Search window for read-only Unity Editor asset or scene-object lookup requests. Always use when the user asks to find, search, show, locate, filter, look up, query, or list concrete assets or scene objects in the current project or scene, even if Unity Search is not named. Covers materials, textures, prefabs, scenes, scripts, shaders, GameObjects, components, Lights, Cameras, UI objects, labels, paths, references, selected or named assets, and asset types. Also use when the user explicitly mentions Unity Search, Quick Search, Search window, open Search, or asks what Unity Search query to use. Do not use for general project overview, project structure, folder-purpose summaries, gameplay/system explanations, how-to programming questions, web search, repository text search, build logs, package installation, menu or settings search, modifying results, or non-Unity filesystem search unless the user explicitly asks to use Unity Search.

unity-technologies/implement-in-app-purchases

Implement, configure, and debug Unity In-App Purchases (IAP) — store connection, product catalog, consumable/non-consumable/subscription purchases, two-step pending-confirm flow, receipt validation, entitlement checking, restore transactions, Apple extensions (promotional purchases, Ask-to-Buy, code redemption), and Google Play extensions (subscription upgrade/downgrade), D2C Capabilities(direct to customer), 3rd party payment provider (Stripe/Coda) via Unity IAP/Unity Cloud. Use when the user needs to add, modify, debug, or migrate from native Android/iOS billing, 3rd party packages(RevenueCat/Adapty/Essential Kit/Unipay supported) to IAP. Triggers on microtransactions (MTX), monetization, real-money purchases, store purchases, buying items, support D2C, purchase via Stripe/Coda, migrate from native billing(Google's BillingClient or Apple's StoreKit/SKPaymentQueue/SKProduct)/RevenueCat/Adapty/EssentialKit/Unipay.

unity-technologies/levelplay-unity-integration

Integrates the LevelPlay Mediation SDK via the Ads Mediation UPM package. Use when a developer asks about adding ads to a Unity game, implementing rewarded, interstitial, or banner ads, setting up ad mediation, configuring ad networks, installing or updating the Ads Mediation package, troubleshooting LevelPlay namespace errors, resolving Android gradle or iOS CocoaPods dependency issues for ads, configuring ATT or privacy settings for ad compliance, tracking impression-level revenue (ILRD), initializing the LevelPlay SDK, or setting up ad unit IDs. Also use when a developer wants to monetize their Unity game with ads, asks how to get started with LevelPlay, ads, or mediation, or needs help with any part of the LevelPlay integration workflow including platform-specific setup for iOS or Android. Also use when upgrading the LevelPlay or IronSource SDK version, migrating from deprecated IronSource.Agent APIs, or migrating a game from Unity Ads to LevelPlay.

unity-technologies/localization

Sets up and configures Unity Localization, including locales, String/Asset Tables, CJK font support, and Addressables workflows. Use when the user wants to add languages to a project, translate UI text, support Asian (CJK) languages with TMP fonts, or mentions i18n, l10n, multilingual support, or making a game support multiple languages.

unity-technologies/manage-sprite-atlas

Manage SpriteAtlas using prebuild pipeline with IPreprocessBuildWithReport (DEFAULT approach). Use it to configure master atlases, variant atlases, texture settings, packing settings, and platform-specific configurations. Use when the user asks about creating sprite atlases, optimizing sprites, configuring atlas settings, adding sprites to atlases, creating variant atlases, implementing automated atlas generation, or runtime sprite atlas access. Always use prebuild approach unless user explicitly requests manual authoring.

unity-technologies/migrate-birp-to-urp

Plans, executes, and troubleshoots Unity projects moving from the Built-in Render Pipeline (BiRP/BIRP/Built-in RP) to the Universal Render Pipeline (URP). Use when the user asks to upgrade, convert, switch, or migrate a project, scene, material, or shader to URP/Universal Render Pipeline; fix pink or magenta materials after URP; convert Built-in materials/shaders; move a 2D project to URP 2D; review lighting, quality, post-processing, baked lightmaps, or reflection probes after URP; or diagnose visual problems after a render-pipeline migration.

相關技能