Communitygithub.com

unity-technologies/initialize-ai-navigation

设置并配置 Unity AI 导航系统——NavMesh 表面、NavMesh 代理、障碍物、链接、修饰符、区域和成本。用于创建可行走的导航网格、添加寻路代理、设置巡逻路线、配置障碍物避让和雕刻、连接分离的 NavMesh、将导航与动画耦合,或排查导航问题。

initialize-ai-navigation 是什么?

This skill (`initialize-ai-navigation`) automates the setup and configuration of Unity's AI Navigation system (AI Navigation package `com.unity.ai.navigation`). It guides developers through a complete workflow: verifying package installation, inspecting the existing scene for NavMesh-related components (NavMeshSurface, NavMeshAgent, NavMeshObstacle, NavMeshLink, NavMeshModifier), gathering user requirements (walkable surfaces, agent types, obstacle behavior, links, area/cost settings), and executing the setup in a prescribed order (surface baking, agent creation, obstacle placement, link connections, modifier assignment, and script integration). It also provides validation steps (checking baked NavMesh visibility, agent type consistency, path validity, obstacle carving, link activation, and area mask correctness) and a final confirmation summary. The skill is designed for use with Unity Editor projects, leveraging the AI Navigation package version 2.x, and can operate with a live Editor connection (e.g., via the `unity-cli` skill) or by analyzing scene/prefab files offline. It references a detailed companion document (`navigation-system.md`) for expanded component API notes, code recipes, and troubleshooting decision trees. The primary use cases include setting up walkable environments, adding pathfinding characters, configuring dynamic obstacles, connecting separate NavMesh regions with links, coupling animation with navigation, and troubleshooting common issues like "agent won't move" or "path not found".

兼容平台~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 之前限定类型。

路由逻辑

用户输入解释
"添加导航" / "设置导航"完整设置:NavMeshSurface + 烘焙 + NavMeshAgent
"让这个角色导航"添加 NavMeshAgent,确保存在 NavMesh
"添加寻路"NavMeshAgent + 移动脚本
"角色不动" / "找不到路径"故障排除——参见参考文档中的故障排除决策树
"避让障碍物"NavMeshObstacle(带雕刻或避让)
"连接两个区域" / "跳跃穿过"区域之间的 NavMeshLink
"在点之间巡逻"NavMeshAgent + 巡逻脚本
"点击移动"NavMeshAgent + 射线检测点击移动脚本
"在导航时为角色设置动画"将 Animator 与 NavMeshAgent 耦合
"不同的代理大小"在导航窗口中配置代理类型
"区域和成本" / "限制区域"NavMesh 区域类型、修饰符和代理区域遮罩

工作流

0. 检查包是否安装

在执行任何操作之前,请验证 com.unity.ai.navigation 是否已安装。如果缺少,请将其添加到 Packages/manifest.json 的 dependencies 中——当编辑器重新获得焦点时,Unity 会解析它,这不需要编辑器连接:

"com.unity.ai.navigation": "<当前 2.x 版本>"

不要自行编造版本字符串。从 Unity 注册表中读取当前版本——https://packages.unity.com/com.unity.ai.navigation 列出了每个已发布版本——或者复制此清单中相邻 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 表面——创建可行走的网格(烘焙它)
  2. NavMesh 代理——添加寻路角色
  3. NavMesh 障碍物——添加动态障碍物
  4. NavMesh 链接——连接不连通的 NavMesh 区域
  5. NavMesh 修饰符 / 修饰符体积——微调区域类型
  6. 脚本——移动、巡逻、点击移动、动画耦合(参见参考文档中的常见示例)

4. 验证

设置完成后,确认:

  • NavMesh 已烘焙且可见(蓝色叠加层)
  • NavMeshSurface 代理类型与 NavMeshAgent 代理类型匹配
  • 代理有一条到其目的地的有效路径
  • 障碍物正确雕刻或阻挡
  • 链接两端均已连接且“已激活”已启用
  • 区域遮罩允许预期的移动
  • 没有冲突的组件(请参阅参考文档中的混合组件指南)
  • 如果 NavMeshAgent 与 Rigidbody 一起使用,则已启用“是运动学的”

5. 最终确认

总结创建或更改的内容:

  • NavMesh 表面:哪个游戏对象、代理类型、几何模式、烘焙状态
  • NavMesh 代理:哪个游戏对象、速度、停止距离、区域遮罩
  • NavMesh 障碍物:哪个游戏对象、形状、是否启用雕刻
  • NavMesh 链接:起点/终点、是否双向、区域类型
  • 脚本:哪些脚本附加到哪些游戏对象
  • 任何需要手动完成的步骤(调整路径点、场景更改后重新烘焙等)

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.

相关技能