Communitygithub.com

unity-technologies/音频设置-混合器

扫描场景和音频资产,将音频源合理分配到现有的音频混合器组中,根据每个音频源的播放内容进行分类。

音频设置-混合器 是什么?

该技能主要用于自动化 Unity 编辑器中音频源的路由分配,将场景中的音频源分类并连接到合适的音频混合器组。它通过扫描场景中的音频源组件及其关联的音频剪辑、游戏对象名称等信息,推断每个音频源所属的类型(如 Foley、对话、音效、音乐等),并生成一个建议的路由方案。技能支持所有 Unity 编辑器版本,但需要编辑器处于运行状态以执行 C# 代码。它利用 Unity 的公共 API 进行音频源分组,但不会自动创建混合器或组,因为这部分没有公共 API。用户需要手动添加缺失的组。该技能适合在用户请求清理混合器分配、将音频路由到混合器或询问某个声音属于哪个组时使用。它特别强调不要使用反射或手动编辑 .mixer 文件来创建组,而是在完成路由后报告所有成功和失败的条目,并明确告知用户场景已被修改但尚未保存。

兼容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/unity-technologies/skills/tree/main/skills/audio-setup-mixers

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

音频混合器设置

将音频源路由到混合器组是一项场景编辑操作,只有正在运行的编辑器才能执行,因此本技能需要能够执行 C# 代码的实时编辑器。第 0 步首先确认这一点。

此技能自动化的内容,以及交还给您的部分。 检查混合器并将音频源路由到组完全使用 Unity 公共 API,而这也是最繁琐的部分 — 遍历数十个音频源并按其播放内容分类。创建混合器或组没有公共 API;它仅存在于 Unity 不承诺保持稳定的类型上。因此,本技能不会在您不知情的情况下创建组。它会盘点现有内容,提出路由方案,请您在音频混合器窗口中添加任何缺失的组,然后自行完成所有路由。

这是一个刻意的限制,而不是需要绕过的缺口。不要使用反射来创建组,也不要手动编辑 .mixer 文件 — 混合器结构无法安全地盲目创建。

第 0 步:确认能够在编辑器中运行 C#

下面的每个 C# 步骤都通过 Unity CLI 在实时编辑器中运行。unity-cli 技能负责让您实现这一点 — 安装 CLI、确认已连接的编辑器、添加项目的 com.unity.pipeline 包、区分真正缺失的编辑器和陷入安全模式的编辑器,以及发现编辑器的命令目录。请先遵循该技能;此处不需要重新推导任何内容。

有两件事它无法为您判断:

  • 您特别需要 eval,而不仅仅是可访问的编辑器。请确认它出现在目录中。它的存在取决于 Pipeline 包的版本,而不是 CLI,因此健康的安装也可能缺少它 — 如果缺失,请说明并停止。
  • 不要退而求其次手动编辑 .mixer 文件。 混合器路由无法安全地盲目创建,因此无法访问的编辑器是一个停止信号,而不是即兴发挥的提示。

一旦 eval 可用,下面的每个 C# 步骤都将通过它运行。

通过已连接编辑器使用 eval 命令运行 C#。从 unity command --format json 发现其参数形式,而不是假设一种形式 — 内联形式是 unity command eval --code '<snippet>',某些 Pipeline 版本还注册了 eval_file 用于从文件运行代码片段。在使用 eval_file 之前先检查目录;它经常缺失。 unity command 默认超时时间为 30 秒。

将 C# 传递给 eval

eval 编译的是语句块,而不是文件。有两个后果,两者都会导致编译错误而不是警告:

  • 没有 using 指令。 编译器将 using UnityEngine; 视为资源释放语句并拒绝它 (CS0210)。
  • 类型必须完全限定。 裸的 AssetDatabase 或 Volume 无法解析 (CS0246 / CS0103),裸的 Object 与 object 有歧义 (CS0104)。

如果下面的代码片段是作为文件编写的(为了可读性或为了保存到项目中而带有 using),则在将其传递给 eval 之前请限定好类型。

第 1 步:预检查

如果用户没有明确要求音频混合器,请确认他们是否要继续进行设置。

然后使用 references/api.md 中的混合器盘点代码片段,通过第 0 步中描述的编辑器来盘点现有内容。这会为您提供项目中的每个混合器以及每个混合器中的组名称。

它返回一个平坦的组列表,而不是父/子树。这对于路由来说已经足够,并且这是公共 API 所能暴露的全部内容。如果对话中需要层级结构,请让用户查看音频混合器窗口并描述它 — 不要使用非公共树 API 来查明。

如果项目完全没有混合器, 请说明并停止,而不是即兴创建一个:创建混合器没有公共 API。请要求用户创建一个(Window → Audio → Audio Mixer,然后点击 Mixers 旁边的 +),并在创建完成后继续。

第 2 步:查找场景引用

查找所有音频源组件,查看它们分配的生成器资产名称,并概括一个合适的类或类别,理想情况下是已经存在的类别。 音频剪辑资产名称示例:

  • "FootStep4_Sound" -> Foley
  • "Dialogue_Female_Scene4" -> Vox/语音/对话
  • "GunShot" -> SFX
  • "Menu_Theme_Variation" -> 音乐

如果分配的资产名称没有描述性或不存在,请尝试查看游戏对象名称或可能的相邻 MonoBehaviour 名称。 如果难以判断或对音频源的使用方式信心较低,请要求创建一个未分类组。

第 3 步:商定组列表,并创建任何缺失的组

将第 2 步的分类作为建议的路由方案呈现 — 每个音频源以及您打算将其发送到的组 — 并与用户一起修改。

等待用户回应后再继续。

如果一个现有组确实涵盖了该类别,优先使用它,即使您会为它起不同的名称。但是不要合并混音工程师会保持分开的类别 — Foley 是 SFX 的一个子集,而不是它的同义词,因此即使存在一个 Foley 组,枪声也不属于 Foley 组。当现有组仅部分覆盖您的类别时,说明哪些匹配、哪些需要新组,并让用户决定。

对于没有匹配组的类别,您无法创建该组 — 没有用于此目的的公共 API。精确地交接,命名混合器和确切的组名称,如 references/api.md 末尾所示。然后在路由之前重新运行盘点代码片段以确认这些组存在并检查它们的拼写。不要假设用户已经做了,也不要假设他们按照您要求的方式拼写。

第 4 步:路由音频源

组列表确定并确认存在后,使用 references/api.md 中的路由代码片段为每个音频源分配输出组。整个过程都使用公共 API,并且整个操作被包装在一个撤销步骤中,以便用户可以一次性撤销所有操作。

将映射键设置为第 2 步分类时使用的标识符。 第 2 步首先读取剪辑资产名称,仅当没有时才回退到游戏对象名称,因此映射接受两者 — 这两个是不同的标识符,使用错误的标识符会导致音频源被遗漏。

需要报告而不是假设的三件事:

  • 代码片段返回的任何 NO SUCH GROUP 条目。 这意味着您期望的组不在混合器中 — 通常是拼写差异。与用户一起解决,不要静默地跳过音频源。
  • 任何 NOT IN THE MAPPING 条目。 这些是您的分类遗漏的音频源。报告路由成功而音频源却被静默地遗漏是最糟糕的结果,因为它看起来像是成功。
  • 场景已被修改,而不是混合器资产。 路由存储在音频源上,因此只有在场景保存后才会持久化。告知用户,并且只在用户同意的情况下保存。

音量、效果和重新父级化不在范围之内。 这些依赖于非公共 API。如果用户要求,说明路由已完成,并让他们在音频混合器窗口中进行混音本身。

参考资料

请参阅 references/api.md

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/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/initialize-ai-navigation

Sets up and configures the Unity AI Navigation system — NavMesh surfaces, NavMesh agents, obstacles, links, modifiers, areas and costs. Use when creating walkable navigation meshes, adding pathfinding agents, setting up patrol routes, configuring obstacle avoidance and carving, connecting separate NavMeshes with links, coupling navigation with animation, or troubleshooting navigation issues.

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.

相关技能