Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .codex-plugin/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"shader-graph"
],
"skills": "./skills/",
"hooks": {},
"requires_local_executor": true,
"interface": {
"displayName": "Unity",
Expand Down
17 changes: 17 additions & 0 deletions .github/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,23 @@ For what each skill covers and how to prompt it, see
[About Unity's plugin](https://docs.unity.com/en-us/ai/unity-plugin/about-unity-plugin),
or browse the [skills](../skills/using-unity/references/).

## What the plugin adds to a session

Besides the skill, the plugin adds one sentence at the start of each session. It tells your agent
to load `using-unity` first when you're working on a Unity project or starting a new game project,
so a request that doesn't mention Unity still reaches the right skill. The sentence is added in
every folder, not only in Unity projects.

How it arrives depends on the agent:

- **Claude Code**: a `SessionStart` hook in `hooks/hooks.json`. It runs one `echo` command that
prints the sentence, and nothing else.
- **GitHub Copilot CLI**: a plugin rule, `com.github.copilot/rules/unity.mdc`.
`copilot instruction list` shows it under "Plugin instructions".
- **Antigravity**: a plugin rule, `rules/AGENTS.md`. `agy plugin list` counts it in the plugin's
components.
- **Codex** and **Grok**: nothing is added. They find `using-unity` from the skill list.

## Works best with the Unity CLI

Many skills drive your open Unity Editor directly: they create GameObjects, change import settings, run C# in the Editor, and check the result, instead of hand-editing scene and asset files. They do this through the [Unity CLI](https://docs.unity.com/en-us/unity-cli), Unity's command-line tool, which also installs Editors, creates and opens projects, and runs builds and tests.
Expand Down
5 changes: 5 additions & 0 deletions com.github.copilot/rules/unity.mdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
description: Unity skills
alwaysApply: true
---
If you're working on a Unity project, or the user is starting a new game project, always load the using-unity skill first: it has references for every part of game development with Unity and its ecosystem. Check its references against each request, even when the request doesn't explicitly mention Unity.
15 changes: 15 additions & 0 deletions hooks/hooks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"hooks": {
"SessionStart": [
{
"matcher": "startup|clear|compact",
"hooks": [
{
"type": "command",
"command": "echo '{\"hookSpecificOutput\":{\"hookEventName\":\"SessionStart\",\"additionalContext\":\"If you\\u0027re working on a Unity project, or the user is starting a new game project, always load the using-unity skill first: it has references for every part of game development with Unity and its ecosystem. Check its references against each request, even when the request doesn\\u0027t explicitly mention Unity.\"}}'"
}
]
}
]
}
}
27 changes: 27 additions & 0 deletions plugin.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"$schema": "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json",
"name": "unity",
"version": "0.1.10-beta",
"description": "Unity's official plugin for coding agents, with curated skills for game development, monetization, and performance optimization.",
"author": {
"name": "Unity Technologies",
"url": "https://unity.com"
},
"homepage": "https://unity.com",
"repository": "https://github.com/Unity-Technologies/unity-agent-plugin",
"license": "LicenseRef-Unity-Companion-License",
"keywords": [
"unity",
"gamedev",
"game-development",
"ui-toolkit",
"ugui",
"2d",
"tilemap",
"in-app-purchases",
"monetization",
"localization",
"multiplayer",
"shader-graph"
]
}
1 change: 1 addition & 0 deletions rules/AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
If you're working on a Unity project, or the user is starting a new game project, always load the using-unity skill first: it has references for every part of game development with Unity and its ecosystem. Check its references against each request, even when the request doesn't explicitly mention Unity.
44 changes: 36 additions & 8 deletions scripts/build-codex-zip.mts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,26 @@
// node scripts/build-codex-zip.mts writes dist/unity-codex-<version>.zip
//
// Run it on a clean checkout of merged main, after the version bump. The zip holds one folder,
// `unity`, with the skills (no evals/ or tests/), both manifests, the README, the license and
// the logos the manifests reference. It refuses to build if the manifests disagree on
// the version or drift from scripts/plugin-metadata.json.
// `unity`, with the skills (no evals/ or tests/), the root plugin.json, the Codex manifest, the
// README, the license and the logos the Codex manifest references. It refuses to build if the
// manifests disagree on the name or version, or drift from scripts/plugin-metadata.json.
//
// The directory takes the package's identity (name, version, description, author) from the root
// plugin.json and everything else from .codex-plugin/plugin.json, because the root manifest has
// no extensions.com.openai. Files for other clients stay out: .claude-plugin/, hooks/, rules/
// and com.github.copilot/.
import { execFileSync } from 'node:child_process';
import { cpSync, existsSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, rmSync, statSync } from 'node:fs';
import {
cpSync,
existsSync,
mkdirSync,
mkdtempSync,
readdirSync,
readFileSync,
rmSync,
statSync,
writeFileSync,
} from 'node:fs';
import { tmpdir } from 'node:os';
import { basename, join, resolve } from 'node:path';

Expand All @@ -22,23 +37,25 @@ execFileSync(process.execPath, [join(root, 'scripts/sync-manifests.mts'), '--che
cwd: root,
stdio: 'inherit',
});
const manifests = ['.codex-plugin/plugin.json', '.claude-plugin/plugin.json'];
const manifests = ['plugin.json', '.codex-plugin/plugin.json'];
const names = new Set<string>();
for (const file of manifests) {
const { version } = JSON.parse(readFileSync(join(root, file), 'utf8')) as { version: string };
const { name, version } = JSON.parse(readFileSync(join(root, file), 'utf8')) as { name: string; version: string };
if (version !== meta.version) fail(`${file} is at ${version}, expected ${meta.version}`);
names.add(name);
}
if (names.size !== 1) fail(`${manifests.join(' and ')} disagree on the name: ${[...names].join(', ')}`);

// 2. Stage the package as <tmp>/unity.
const excluded = new Set(['evals', 'tests', '.DS_Store', 'Thumbs.db']);
const contents = [
'skills',
'plugin.json',
'.codex-plugin',
'.claude-plugin',
'README.md',
'LICENSE.md',
'assets/unity.svg',
'assets/unity-small.svg',
'assets/unity-tile.svg', // the icon .claude-plugin/plugin.json points to
];
const stage = mkdtempSync(join(tmpdir(), 'unity-codex-'));
const pkg = join(stage, 'unity');
Expand All @@ -52,6 +69,17 @@ try {
});
}

// The Codex manifest sets "hooks": {} so that a git install never picks up hooks/hooks.json,
// which is Claude Code's. The zip has no hooks/ folder, so the key has nothing to switch off
// here, and the plugin directory takes no plugins with lifecycle hooks. Leave it out, so the
// uploaded manifest declares none.
const codexManifest = join(pkg, '.codex-plugin/plugin.json');
const { hooks, ...packed } = JSON.parse(readFileSync(codexManifest, 'utf8')) as Record<string, unknown>;
if (hooks !== undefined && JSON.stringify(hooks) !== '{}') {
fail('.codex-plugin/plugin.json declares hooks; the plugin directory takes no plugins with lifecycle hooks');
}
writeFileSync(codexManifest, `${JSON.stringify(packed, null, 2)}\n`);

// 3. Check what was staged before zipping it.
const skills = readdirSync(join(pkg, 'skills')).filter((d) =>
existsSync(join(pkg, 'skills', d, 'SKILL.md')),
Expand Down
3 changes: 2 additions & 1 deletion scripts/plugin-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@
"localization",
"multiplayer",
"shader-graph"
]
],
"nudge": "If you're working on a Unity project, or the user is starting a new game project, always load the using-unity skill first: it has references for every part of game development with Unity and its ecosystem. Check its references against each request, even when the request doesn't explicitly mention Unity."
}
72 changes: 71 additions & 1 deletion scripts/sync-manifests.mts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@
// To release, change "version" in plugin-metadata.json and run the script without --check.
// Platform-only fields (descriptions, the Codex interface block, Antigravity prompts) stay in
// each manifest and are not touched.
import { readFileSync, writeFileSync } from 'node:fs';
//
// It also writes the session-start nudge ("nudge" in plugin-metadata.json) into the three files
// that deliver it, so they always carry the same sentence. See `nudgeFiles` below.
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
import { dirname } from 'node:path';

type Json = string | number | boolean | null | Json[] | { [key: string]: Json };
type JsonObject = { [key: string]: Json };
Expand All @@ -21,6 +25,7 @@ interface Metadata {
license: string;
category: string;
keywords: string[];
nudge: string;
}

interface Marketplace extends JsonObject {
Expand All @@ -34,6 +39,14 @@ const shared = ['version', 'author', 'homepage', 'repository', 'license', 'keywo
// Each target names a manifest and where each shared key lives in it.
const targets: { file: string; set: (manifest: JsonObject) => void }[] = [
{ file: '.claude-plugin/plugin.json', set: (m) => assign(m, shared) },
{
// The Agent Plugins manifest at the plugin root. Copilot CLI reads com.github.copilot/ only
// when it exists, Grok reads it before .claude-plugin/plugin.json, and OpenAI's plugin
// directory takes the package's identity from it. It has no extensions.com.openai, so
// Codex and the directory still read their settings from .codex-plugin/plugin.json.
file: 'plugin.json',
set: (m) => assign(m, shared),
},
{
file: '.codex-plugin/plugin.json',
set: (m) => {
Expand Down Expand Up @@ -107,6 +120,63 @@ for (const { file, set } of targets) {
else writeFileSync(file, after);
}

// The session-start nudge: one sentence telling the agent to open using-unity first, delivered
// in each client's own form.
// hooks/hooks.json Claude Code: a SessionStart hook prints it as additionalContext.
// The matcher leaves out resume, where the saved text is replayed.
// com.github.copilot/rules/unity.mdc Copilot CLI: an always-on plugin rule.
// rules/AGENTS.md Antigravity: an always-on plugin rule.
// Codex and Grok get none. A Codex plugin hook needs the user's approval again after every
// plugin update, so .codex-plugin/plugin.json sets "hooks": {} to keep Codex from picking up
// hooks/hooks.json. Grok runs hooks/hooks.json and ignores what a SessionStart hook prints.
const nudgeFiles: { file: string; content: string }[] = [
{
file: 'hooks/hooks.json',
content: `${JSON.stringify(
{
hooks: {
SessionStart: [
{ matcher: 'startup|clear|compact', hooks: [{ type: 'command', command: nudgeCommand(meta.nudge) }] },
],
},
},
null,
2,
)}\n`,
},
{
// Copilot CLI lists the rule only with a description and alwaysApply: true, in a .mdc file.
file: 'com.github.copilot/rules/unity.mdc',
content: `---\ndescription: Unity skills\nalwaysApply: true\n---\n${meta.nudge}\n`,
},
{ file: 'rules/AGENTS.md', content: `${meta.nudge}\n` },
];

// The hook command runs in sh, Git Bash or PowerShell, whichever the client picks on the
// user's machine, with no program or file it could depend on. A single-quoted `echo` is the
// one form all of them print unchanged. An apostrophe would end the quoting, so it is written
// as the JSON escape \u0027, which the client decodes.
function nudgeCommand(text: string): string {
if (/[\\"\r\n]/.test(text)) {
throw new Error(
'"nudge" in scripts/plugin-metadata.json has a backslash, a double quote or a line break. ' +
'Shells disagree on how `echo` prints those, so the hook would break in some of them. Reword it.',
);
}
const output = JSON.stringify({ hookSpecificOutput: { hookEventName: 'SessionStart', additionalContext: text } });
return `echo '${output.replaceAll("'", '\\u0027')}'`;
}

for (const { file, content } of nudgeFiles) {
const before = existsSync(file) ? readFileSync(file, 'utf8').replace(/\r\n/g, '\n') : null;
if (before === content) continue;
if (check) drifted.push(file);
else {
mkdirSync(dirname(file), { recursive: true });
writeFileSync(file, content);
}
}

// The sample `codex plugin list`, `agy plugin list` and `copilot plugin list` output in the
// README shows the version. Only those three lines are matched, so other version numbers in
// the README are left alone.
Expand Down
3 changes: 2 additions & 1 deletion skills/using-unity/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ A skill's own files are in its folder, `references/<name>/`. When the skill give

A skill may tell you to use, load or check for another skill by name, for example "use the `unity-cli` skill" or "check that `ui` is in your client's skills". Every skill in the index below is installed with this one, though only `using-unity` is listed in your client's skills. Treat each of them as available: when a skill names one, read its file from the index and follow it, and don't offer to install it. Where a skill's files mention its `SKILL.md`, that is its `<name>.md` file here.

## Index (33 skills, A to Z)
## Index (34 skills, A to Z)

- **build-gtk**: Builds graph tools with Unity Graph Toolkit (GTK) on 6.6+, state machines on 6.7+, and importers for runtime assets. Use this skill for graph, node or state machine editors, or GraphView migrations. Not for Shader Graph, VFX Graph or Animator. File: `references/build-gtk/build-gtk.md`
- **build-live-game**: Builds and operates a live game backend on Unity Gaming Services. Make sure to use this skill when the user wants sign-in or sign-in checks, trusted server-side game logic, player progress, remote config, achievements, battle passes or leaderboards. File: `references/build-live-game/build-live-game.md`
Expand All @@ -46,6 +46,7 @@ A skill may tell you to use, load or check for another skill by name, for exampl
- **optimize-audio**: Optimizes audio memory, CPU cost, and playback quality through import settings and mixer configuration. Use when asked to reduce audio memory or Audio Mixer CPU cost, change clip Load Types, sample rates or codecs, or force 3D audio to mono. File: `references/optimize-audio/optimize-audio.md`
- **optimize-text-mesh-pro**: Optimizes TextMeshPro rendering, memory, and font setup, including font asset stacks, fallback atlases, SDF quality, and worldspace text. Use when the user asks about TextMeshPro font assets, CJK font fallbacks, or TMP memory, build size, quality or performance, not about translating text. File: `references/optimize-text-mesh-pro/optimize-text-mesh-pro.md`
- **optimize-web**: Optimizes Unity WebGL and WebGPU builds for smaller downloads, faster loading, and smoother browser performance. Use when asked to shrink a web build, speed up its load, or fix stutter, memory or battery problems in the browser. File: `references/optimize-web/optimize-web.md`
- **project-auditor-fixes**: Runs a Project Auditor scan on a Unity project and fixes the reported issues in small, reviewable batches. Use when asked to audit a Unity project and fix the code, asset or settings issues Project Auditor finds. File: `references/project-auditor-fixes/project-auditor-fixes.md`
- **route-audio-to-mixer-groups**: Routes 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. File: `references/route-audio-to-mixer-groups/route-audio-to-mixer-groups.md`
- **setup-vivox-voice-chat**: Adds and configures in-game voice and text chat with Unity Vivox. Use when asked to add voice or text chat to a multiplayer game, such as team channels, proximity voice, mute controls or private messages. File: `references/setup-vivox-voice-chat/setup-vivox-voice-chat.md`
- **shader-graph-create-custom-node**: Generates custom Shader Graph nodes from HLSL code by reflection. Use when asked for a new Shader Graph node, or to make existing HLSL work as a reflected function node. File: `references/shader-graph-create-custom-node/shader-graph-create-custom-node.md`
Expand Down
16 changes: 16 additions & 0 deletions skills/using-unity/references/project-auditor-fixes/SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Security notes: project-auditor-fixes

This skill has the agent read state from the user's open Unity Editor through `unity command script eval` when it checks a suspected fault in Play mode while fixing Project Auditor issues. Automated skill scanners flag running code in the Editor as a powerful capability. It is intentional, and it is limited by the safeguards below.

## Accepted risks

| Risk | Capability | Why it is accepted |
|---|---|---|
| `SEC_POWER_CAP` | Runs C# in the user's open Editor through `unity command script eval` | It only reaches the Editor the user already has open, on their own machine, as that user, so it grants nothing they couldn't do themselves. `script eval` sits behind the Pipeline capability gate. No code fetched from a remote source is run. |

## Mitigations

- **Only the user's own Editor.** `unity command script eval` talks to the Editor open on this machine. It can't reach another machine or another user's Editor.
- **Capability gate.** `script eval` is only available when the project's Pipeline package provides it.
- **No remote code.** The agent runs C# it writes itself to read Editor state. Nothing downloaded from outside is executed.
- **Read only, once.** The skill enters Play mode at most once, to chase a fault it already suspects, and reads state instead of adding logging or verification code to the user's scripts. It creates a restore point before it changes the project.
Loading
Loading