Communitygithub.com

unity-technologies/manage-sprite-atlas

プリビルドパイプラインを使用してSpriteAtlasを管理します(デフォルトアプローチ)。マスターアトラス、バリアントアトラス、テクスチャ設定、パッキング設定、プラットフォーム固有の構成を行います。スプライトアトラスの作成、スプライト最適化、アトラス設定の構成、スプライトの追加、バリアントアトラスの作成、自動アトラス生成、ランタイムスプライトアトラスアクセスに関するユーザーリクエストに使用します。ユーザーが明示的に手動作成を要求しない限り、常にプリビルドアプローチを使用します。

manage-sprite-atlas とは?

このスキルは、UnityプロジェクトにおけるSpriteAtlasの作成と管理を自動化するためのエディターセーフな手続き型知識を提供します。V2アーキテクチャに基づき、エディターでのオーサリング(SpriteAtlasAsset)とランタイムアクセス(SpriteAtlas)を厳密に分離します。デフォルトでは、`IPreprocessBuildWithReport`を使用したプリビルド生成アプローチを採用し、ビルドパイプライン内で自動的にアトラスを生成・更新します。Addressablesを使用したレイトバインディング(オンデマンド読み込み)もサポートしており、DLCや大規模アセットの管理に適しています。 スキルは、`resources/`ディレクトリに38ファイルの実用的なC#コードとリファレンスを同梱しており、カスタムパッカー、バリアント、プラットフォーム設定、ランタイムアクセスをカバーしています。実装前に、プロジェクト内の既存スクリプトのチェック、配信メカニズム(ビルトインかAddressablesか)の決定、Sprite Packerモードの有効化を必須とします。特にSprite Packerモードが無効だとアトラスが機能しないため、設定後に必ず読み取り確認を行います。 サポート対象は、Unityエディターで動作する任意のUnityプロジェクトです。C#コード、CLIコマンド、ファイルパス、環境変数名、URL、インラインコードスパンは翻訳せず保持します。

対応~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/unity-technologies/skills/tree/main/skills/manage-sprite-atlas

お気に入りのAIに質問する

このエージェントスキルを事前に読み込んだ状態で新しいチャットを開きます。

ドキュメント

Unity SpriteAtlas V2

Unityプロジェクトでアトラスをスクリプト化するためのエディターセーフな手続き型知識を提供します。V2はエディターのオーサリングとランタイムアクセスを厳密に分離します。

⚠️ 重要なV2の原則: SpriteAtlasはランタイム専用です。SpriteAtlasAssetはエディター専用です。コンテキストを混在させないでください。常にV2を使用します。

🚨 重要: 実装前の必須チェックとユーザー入力

コードを生成する前に、必ず以下のチェックを実行し、質問を行ってください:

コードを書く前に同梱リソースを読む(必須)

このスキルはresources/配下に動作するC#を提供しており、アトラスコードの問題のほとんどは、これを読まずにコードを書くことで発生します。使用するパスに対応するファイルを開いてから、コードを書いてください。

このパスを使用する場合最初に読むファイル
アトラス作業全般resources/authoringvsruntime.cs, references/common-errors.md
プリビルド生成(デフォルト)resources/spriteatlasprebuildgenerator.cs, resources/enablespritepacking.cs, resources/savespriteatlasasset.cs
オプションB: Addressablesレイトバインディングresources/buildaddressablespostprocess.cs, resources/spriteatlaslatebinding.cs, resources/handlelatebinding.cs
古いAPIを使用する可能性があるものresources/deprecatedmethods.cs, resources/dontscriptspriteatlasineditor.cs, resources/dontpackinruntimebuilds.cs

resources/には38のファイルがあり、カスタムパッカー、バリアント、プラットフォーム設定、ランタイムアクセスをカバーしています。上記の表にないタスクの場合は、新しいアプローチを発明するのではなく、ディレクトリを参照してください。メモリからAPIを使用することは、アトラスが正常にインポートされてもランタイムで何もしない原因として最も一般的です。

0. 既存スクリプトの確認(必須の最初のステップ)

コードを生成する前に、プロジェクト内にこのスキルで生成された既存のSpriteAtlasスクリプトをスキャンしてください。

識別子を含むファイルを検索します: // [UNITY-SKILL:SPRITEATLAS]

既存のスクリプトが見つかった場合、必ず以下の形式でユーザーに質問してください:

"プロジェクトに既存のSpriteAtlasスクリプトが見つかりました:

プリビルドジェネレーター:

  • Assets/Editor/SpriteAtlas/SpriteAtlasPrebuildGenerator.cs

Addressablesビルダー:

  • Assets/Editor/SpriteAtlas/BuildAddressablesPostprocess.cs

ランタイムローダー:

  • Assets/Scripts/SpriteAtlas/SpriteAtlasLateBinding.cs

どうしますか?"

次にオプションを提示します:

  • オプションA: 既存スクリプトを更新(要件が変わった場合に推奨)

    • 既存のパスでスクリプトを再生成
    • ファイルの場所を保持
    • 最新バージョンに更新
    • ⚠️ カスタム変更は上書きされる可能性があります
  • オプションB: 異なる名前で新しいスクリプトを作成

    • 既存のスクリプトと並行して生成
    • 複数のアトラス構成が可能
    • 元のスクリプトは変更されません
    • 新しい名前/パスを指定する必要があります
  • オプションC: 中止(既存のものをそのまま保持)

    • コード生成なし
    • プロジェクトへの変更なし
    • 現在の設定を維持したい場合に使用

ユーザー選択の処理:

  • Aが選択された場合: 既存のパスで再生成し、バージョンを2.0.1以上に増加
  • Bが選択された場合: 新しいスクリプト名(例: "SpriteAtlasPrebuild_Custom.cs")を尋ねてから生成
  • Cが選択された場合: すぐに停止し、変更がないことをユーザーに通知

1. 配信メカニズム(必須)

質問: "スプライトアトラスをどのように配信しますか?"

オプションA: ビルトインデータ(即時読み込み)

  • アトラスはビルドに含まれ、即座に読み込まれます
  • includeInBuild = true を設定
  • 適している: コアUI、メインゲームプレイスプライト、常に必要なアセット
  • 長所: シンプル、追加パッケージ不要、即時アクセス
  • 短所: 初期ビルドサイズが増加、新しいビルドなしでは更新不可

オプションB: Addressablesを介したレイトバインディング(オンデマンド読み込み)

  • アトラスはビルドに含まれず、Addressables経由でオンデマンド読み込み
  • includeInBuild = false を設定
  • 各アトラス用のAddressablesエントリを作成
  • プリビルドステップとしてアドレサブル設定を追加
  • 🚨 必須: ビルドステップとしてAddressablesコンテンツをビルド
  • 🚨 必須: レイトバインディングランタイムローダースクリプトを作成
  • 適している: DLCコンテンツ、オプション機能、大規模アセット、ダウンロード可能コンテンツ
  • 長所: 初期ビルドが小さい、独立して更新可能、オンデマンド読み込み
  • 短所: Addressablesパッケージが必要、非同期読み込み、ネットワーク依存
使用ケース推奨
常に表示されるコアUIスプライトオプションA: ビルトイン
チュートリアルやオンボーディングスプライトオプションA: ビルトイン
レベル固有のスプライト(100レベル以上)オプションB: Addressables
DLCや季節コンテンツオプションB: Addressables
ローカライズされたUIスプライト(複数言語)オプションB: Addressables
キャラクタースキンやコスメティックオプションB: Addressables

2. SpritePackerモード(必須)

アトラスを作成する前にSprite Packerモードを有効にし、その後設定を読み戻して、適用されたことを確認してください。 resources/enablespritepacking.csのコードを使用します。これはEditorSettings.spritePackerModeを設定し、インポーターのパッキング設定を構成します。

このステップが、生成するアトラスが実際に機能するかどうかを決定します。DisabledはSpritePackerModeのゼロ値であり、誰も設定していないプロジェクトではパッキングが無効になります。無効の状態で作成されたアトラスはインポートされ、アセットとして表示され、完成したように見えますが、パックされることはありません。Unityはインスペクターで「Sprite Atlas packing is disabled」と表示します。ワークフローの他の部分は失敗しないため、この方法で出荷されたアトラスは成功として読み取られます。プロジェクトがすでに設定されていると想定しないでください。値を読み取ってください。

そのため、「設定した」だけでは完了と見なさないでください。設定後、EditorSettings.spritePackerModeを読み戻し、Disabledでないことを確認し、実際に読み取った値を報告してください。読み戻せない場合は、書き込みが成功したと仮定せず、その旨を伝えてください。

メタファイルを直接編集しないでください。

🚨 重要: デフォルトアプローチはプリビルド生成

ビルドパイプライン中に自動的にSpriteAtlasを生成または更新するために、常にIPreprocessBuildWithReportを使用してください。 これはデフォルトであり、必須のアプローチです。ユーザーが明示的に手動作成を要求した場合のみ、手動作成を使用してください。

❌ 手動メニューアイテムスクリプトを作成しない

明示的に要求されない限り、アトラス生成のために[MenuItem]属性を持つスクリプトを作成しないでください。 プリビルドアプローチにより、手動クリックの必要性がなくなります。手動作成は以下の場合のみ使用: 手動最適化レイアウト、特定のスプライト配置、エディタープレビュー要件。詳細は「発展編: 手動作成」を参照してください。

🚨 重要: スプライトソース場所の制限

プロジェクトのAssetsフォルダーからのみスプライトを追加してください。Unityビルトインアセット、パッケージ、外部の場所からは絶対に追加しないでください。 UnityビルトインアセットはSpriteAtlasにパックできず、パッケージアセットはインポート/依存関係の問題を引き起こす可能性があります。

重要なV2アーキテクチャ

コンテキストコンポーネント目的許可される使用法
エディターSpriteAtlasAssetオーサリングエディタースクリプト、プリビルド、アセット作成
ランタイムSpriteAtlas読み込みとアクセスランタイムスクリプト、Addressables、レイトバインディング
決して混在させない両方-SpriteAtlasAssetをビルドに含めない、ランタイムでSpriteAtlasAssetを参照しない、エディターでSpriteAtlasをロードしない

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.

関連スキル