Communitygithub.com

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.

manage-sprite-atlas 是什么?

manage-sprite-atlas is a Claude Code agent skill that 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.

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

在你喜欢的 AI 中提问

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

文档

Unity SpriteAtlas V2

Provides editor-safe procedural knowledge for scripting atlases in Unity projects. V2 enforces strict separation between editor authoring and runtime access.

⚠️ Critical V2 Principle: SpriteAtlas is runtime-only. SpriteAtlasAsset is editor-only. Never mix contexts. Always use V2.

🚨 CRITICAL: Required Checks and User Inputs Before Implementation

ALWAYS perform these checks and ask these questions BEFORE generating any code:

Read the shipped resources before writing code (REQUIRED)

This skill ships working C# under resources/, and the atlas code that goes wrong is almost always code written without reading it first. Open the files for the path you are taking, then write.

Taking this pathRead first
Any atlas work at allresources/authoringvsruntime.cs, references/common-errors.md
Prebuild generation (the default)resources/spriteatlasprebuildgenerator.cs, resources/enablespritepacking.cs, resources/savespriteatlasasset.cs
Option B, Addressables late-bindingresources/buildaddressablespostprocess.cs, resources/spriteatlaslatebinding.cs, resources/handlelatebinding.cs
Anything that might use an older APIresources/deprecatedmethods.cs, resources/dontscriptspriteatlasineditor.cs, resources/dontpackinruntimebuilds.cs

resources/ holds 38 files in all, covering custom packers, variants, platform settings, and runtime access. Browse the directory when your task is not in the table above rather than inventing an approach. Reaching for the API from memory instead of reading these is the single most common cause of an atlas that imports cleanly and then does nothing at runtime.

0. Check for Existing Scripts (REQUIRED FIRST STEP)

BEFORE generating any code, scan the project for existing SpriteAtlas scripts generated by this skill.

Search for files containing the identifier: // [UNITY-SKILL:SPRITEATLAS]

If existing scripts are found, ALWAYS ask the user with this format:

"I found existing SpriteAtlas scripts in your project:

Prebuild Generator:

  • Assets/Editor/SpriteAtlas/SpriteAtlasPrebuildGenerator.cs

Addressables Builder:

  • Assets/Editor/SpriteAtlas/BuildAddressablesPostprocess.cs

Runtime Loader:

  • Assets/Scripts/SpriteAtlas/SpriteAtlasLateBinding.cs

What would you like to do?"

Then present options:

  • Option A: Update existing scripts (Recommended if requirements changed)

    • Regenerates scripts at existing paths
    • Preserves file locations
    • Updates to latest version
    • ⚠️ May overwrite custom modifications
  • Option B: Create new scripts with different names

    • Generates alongside existing scripts
    • Allows multiple atlas configurations
    • Original scripts remain unchanged
    • You'll need to specify new names/paths
  • Option C: Abort (keep existing unchanged)

    • No code generation
    • No changes to project
    • Use this if you want to keep current setup

User Choice Handling:

  • If A chosen: Regenerate at existing paths, increment version to 2.0.1+
  • If B chosen: Ask for new script names (e.g., "SpriteAtlasPrebuild_Custom.cs"), then generate
  • If C chosen: Stop immediately, inform user no changes were made

1. Delivery Mechanism (REQUIRED)

Ask: "How do you want to deliver the sprite atlases?"

Option A: Built-in Data (Immediate Loading)

  • Atlases are included in the build and loaded immediately
  • Set includeInBuild = true
  • Suitable for: Core UI, main gameplay sprites, always-needed assets
  • Pros: Simple, no additional packages, instant access
  • Cons: Increases initial build size, cannot update without new build

Option B: Late-Binding via Addressables (On-Demand Loading)

  • Atlases are NOT included in build, loaded on-demand via Addressables
  • Set includeInBuild = false
  • Create Addressables entries for each atlas
  • Add addressable setup as prebuild step
  • 🚨 REQUIRED: Build Addressables content as build step
  • 🚨 REQUIRED: Create late-binding runtime loader script
  • Suitable for: DLC content, optional features, large assets, downloadable content
  • Pros: Smaller initial build, can update independently, on-demand loading
  • Cons: Requires Addressables package, async loading, network dependency
Use CaseRecommended
Core UI sprites that are always visibleOption A: Built-in
Tutorial or onboarding spritesOption A: Built-in
Level-specific sprites (100+ levels)Option B: Addressables
DLC or seasonal contentOption B: Addressables
Localized UI sprites (multiple languages)Option B: Addressables
Character skins or cosmeticsOption B: Addressables

2. SpritePacker Mode (REQUIRED)

Enable Sprite Packer mode before creating atlases, then read the setting back and confirm it took. Use the code in resources/enablespritepacking.cs; it sets EditorSettings.spritePackerMode and configures the importer's packing settings.

This is the step that decides whether the atlas you produce is real. Disabled is the zero value of SpritePackerMode, so any project where nobody has set it carries packing Disabled, and an atlas created while it is Disabled still imports, still shows up as an asset, and still looks finished, but can never pack. Unity says so in the Inspector: "Sprite Atlas packing is disabled". Nothing else in the workflow fails, so an atlas shipped this way reads as a success. Do not assume a project is already configured: read the value.

So do not treat "I set it" as done. After setting it, read EditorSettings.spritePackerMode back, confirm it is not Disabled, and report the value you actually read. If you cannot read it back, say so rather than assuming the write landed.

DO NOT edit meta files DIRECTLY.

🚨 CRITICAL: Default Approach is Prebuild Generation

ALWAYS use IPreprocessBuildWithReport to automatically generate or update SpriteAtlases during the build pipeline. This is the DEFAULT and REQUIRED approach unless the user EXPLICITLY requests manual authoring.

❌ DO NOT Create Manual Menu Item Scripts

NEVER create scripts with [MenuItem] attributes for atlas generation unless explicitly requested. The prebuild approach eliminates the need for manual clicks. Only use manual authoring for: Hand-optimized layouts, specific sprite arrangements, or editor preview requirements. See Advanced: Manual Authoring.

🚨 CRITICAL: Sprite Source Location Restriction

ONLY add sprites from the project's Assets folder. NEVER add sprites from Unity built-in assets, packages, or external locations. Unity built-in assets cannot be packed into SpriteAtlas, and package assets may cause import/dependency issues.

Critical V2 Architecture

ContextComponentPurposeAllowed Usage

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/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/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.

相关技能