Communitygithub.com

unity-technologies/levelplay-unity-integration

整合 LevelPlay 廣告中介 SDK,透過 Ads Mediation UPM 套件在 Unity 遊戲中實現獎勵廣告、插頁廣告、橫幅廣告,並設定廣告中介與平台專屬配置。

levelplay-unity-integration 是什麼?

此技能專門用於 Unity 開發者整合 LevelPlay 廣告中介 SDK,支援 Android 與 iOS 平台。技能涵蓋從全新安裝、SDK 版本遷移、Unity Ads 遷移,到疑難排解建置錯誤與實作進階功能(如 ATT、GDPR、ILRD)等完整工作流程。它透過步驟化指引,要求每一步確認專案環境、安裝 Ads Mediation UPM 套件、設定 Android Gradle 與 iOS CocoaPods 依賴、初始化 SDK,並實作三種主要廣告格式。技能嚴格遵循 `SKILL.md` 中的工作流程,避免主動新增步驟或使用通用知識,確保整合過程的正確性與一致性。

相容平台✓Claude Code~Codex CLI~Cursor
npx skills add https://github.com/unity-technologies/skills/tree/main/skills/levelplay-unity-integration

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

LevelPlay Unity 套件/SDK 整合

基礎編輯器端的檢查應基於實際專案而非假設 — 讀取專案檔案,或要求使用者在編輯器中確認。此技能產生的 C# 腳本為 MonoBehaviour 檔案,供使用者儲存至其專案,非用於內聯執行。

此技能僅涵蓋 LevelPlay 整合路徑,不包含其他中介 SDK。若使用者明確詢問替代方案,應承認替代方案存在,並引導其參考相關廠商的文件 — 請勿描述、說明或對競爭產品做出主張。

遵循以下步驟,僅提供此技能所述之檔案與配置。請勿主動新增步驟、建立檔案或根據通用知識提出建議。若使用者提出超出此技能範圍的問題,請先檢查技能與參考檔案以確認是否涵蓋。若未涵蓋,則使用通用知識回應,但請勿因此將額外步驟或檔案納入整合工作流程。

依序遵循整合工作流程,一次一個步驟。僅詢問目前步驟所需的問題 — 請勿提前收集未來步驟的資訊。在每個檢查點等待使用者回應後再繼續。

LevelPlay 是 Unity 的廣告中介平台:它將您的遊戲同時連接至多個廣告網路,並對多個廣告網路與出價者執行統一拍賣,以最大化每次曝光的競爭。本指南逐步引導您完成完整整合:安裝 SDK、配置 Android 與 iOS 的依賴項、在專案中初始化 LevelPlay,以及實作獎勵廣告、插頁廣告與橫幅廣告。若您已部分設定完成,可直接跳至相關步驟。

此 SKILL.md 為工作流程主幹。它保留決策點、檢查點與確切問題;較長的程式碼、完整的 API 細節與邊緣情況則位於 references/ 中,並從相關步驟連結。請在執行該步驟時閱讀連結的參考檔案 — 請勿僅依靠通用知識回答。

整合工作流程

0. 全新整合或遷移?

詢問:「您是要開始新的 LevelPlay 整合、遷移現有整合(從較舊的 SDK 版本或從 Unity Ads),還是疑難排解現有設定?」

  • 全新整合:繼續至步驟 1。
  • 遷移(SDK 升級、取代 IronSource.Agent API、從 Unity Ads 遷移,或修復 Maven Central Android 建置失敗):讀取 references/migration-sdk-9.md。詢問適用於哪個情境 — A = SDK 升級、B = init API 遷移、C = 廣告單元 API 遷移、D = Maven Central 建置失敗、E = Unity Ads 遷移 — 然後遵循對應的情境。套用所有程式碼變更後,執行遷移完整性檢查清單(參考檔案的 C5 節)— 它能捕捉到逐行轉譯遺漏的需求,因為舊程式碼中沒有對應行。然後要求使用者在 Unity 控制台中檢查編譯錯誤,並在呈現結果前修正任何錯誤。若無法檢視控制台,請勿封鎖或重試:列出您變更的檔案、說明要檢查的內容,然後繼續。
  • 疑難排解或新增至現有設定(ATT、GDPR、ILRD、測試套件、全新整合的建置錯誤,或為已運作的整合新增功能):識別使用者需求,並直接前往「何時閱讀詳細參考」中的相關步驟或參考檔案。

1. 驗證 Unity 環境

透過驗證 Assets/ 與 ProjectSettings/ 目錄是否存在,檢查使用者是否在 Unity 專案中工作。若非 Unity 專案,請指示使用者導航至他們的 Unity 專案目錄。若找不到這些目錄但使用者認為他們在正確的位置,請詢問:「看起來您可能未位於專案根目錄 — 能否導航至 Unity 專案的頂層資料夾,並確認您可以看到 Assets/ 與 ProjectSettings/ 目錄?」

2. 了解業務目標

在實作廣告單元之前,先確定使用者最佳化優先順序,以推薦適當的廣告單元策略。詢問:

「您的主要最佳化目標是什麼?」

  • 收益導向:最大化廣告收益與曝光機會
  • 使用者體驗導向:優先考慮遊戲流程與使用者滿意度
  • 平衡:同時最佳化收益與使用者體驗
  • 還不確定:預設為平衡,然後繼續。在步驟 8 時,簡短說明由於使用者不確定,因此使用平衡策略,並邀請他們在看到格式選項後表示不同的偏好。

記錄此答案,以便在步驟 8 進行後續策略建議。

3. 透過 UPM 安裝 LevelPlay SDK

若 SDK 看起來已安裝: 請勿僅憑信任,也不要要求使用者為您閱讀套件管理員視窗。讀取 Packages/packages-lock.json 並尋找 com.unity.services.levelplay。若存在,請告知已解析的版本,並繼續至步驟 4。若不存在,則無論對話中假設為何皆視為未安裝:繼續執行以下安裝程序。

引導使用者使用 Unity 套件管理員安裝 LevelPlay Unity 套件:

  1. 開啟 Unity → Window > Package Manager
  2. 選取 Unity Registry 下拉選單或 Services 分頁
  3. 在套件管理員搜尋列中輸入 Ads Mediation
  4. 確認套件名稱完全相符:正確的套件標題為 Ads Mediation。請勿安裝以下任一套件:
    • Ads IAP Mediation Adaptor(一個獨立的應用程式內購買套件,非 LevelPlay SDK)
    • Advertisement Legacy(一個已棄用的套件,與目前的 LevelPlay 整合不相容)
  5. 點擊 Install 按鈕
  6. 等待套件下載與匯入

安裝套件時,您可能會看到安裝 Mobile Dependency Resolver 的提示 — 若出現,請點擊 Import。這將在下一步中詳細說明。

然後透過讀取專案而非詢問來驗證它是否已解析。 套件 ID 為 com.unity.services.levelplay(其套件管理員顯示名稱為 Ads Mediation;ID 是專案檔案記錄的內容)。檢查以下兩個檔案:

  • Packages/manifest.json 列出專案要求的內容。com.unity.services.levelplay 必須出現在 dependencies 下方。
  • Packages/packages-lock.json 記錄 Unity 實際解析的內容。相同的 ID 也必須出現於此,並帶有具體版本。此檔案回答「是否已安裝」的問題,是應信任的檔案。

兩者皆為專案中的純 JSON,此檢查無需編輯器、無需 CLI,也無需使用者提供任何資訊。請直接讀取它們。

這是硬性關卡,而非形式上的步驟。 在 com.unity.services.levelplay 出現在 packages-lock.json 中之前,請勿撰寫、產生或貼上任何一行 LevelPlay 程式碼。跳過此步驟會產出看似正確、但無法在任何地方編譯,並在每個 LevelPlay 類別上出現 CS0246 錯誤的程式碼。

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

相關技能