最佳化初始化和廣告載入程序
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
從 Google Mobile Ads (GMA) SDK 21.0.0 版開始,您可以啟用最佳化 SDK 初始化和廣告載入功能,提升廣告整體回應速度,並協助避免應用程式發生「應用程式沒有回應」(ANR) 錯誤。
本指南將說明啟用這些最佳化功能時需要進行的變更。
需求條件
- Google Mobile Ads Unity 外掛程式 7.2.0 以上版本。
更新 Google 行動廣告設定
Google Mobile Ads SDK 預設會啟用最佳化功能,並指示 SDK 在背景執行緒上處理初始化和廣告載入工作。
以下標記適用於 Google Mobile Ads SDK 設定中可編寫指令碼的物件:
請檢查下列設定,指示 SDK 在主要執行緒上初始化及載入廣告:
設定 | 行為 |
停用初始化最佳化功能 |
停用最佳化 MobileAds.initialize() 初始化呼叫。 |
停用廣告載入最佳化功能
|
針對所有廣告格式最佳化廣告載入呼叫。 |
停用最佳化廣告載入呼叫。 |
您可以透過 Unity 資產選單存取 Google 行動廣告設定:
「素材資源」>「Google 行動廣告」>「設定」
選取後,設定 UI 會顯示在 Unity 編輯器的檢查器視窗中。

請注意,您可以在同一應用程式中,擇一或同時啟用兩個選項。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-08-31 (世界標準時間)。
[null,null,["上次更新時間:2025-08-31 (世界標準時間)。"],[[["\u003cp\u003eStarting with Google Mobile Ads SDK version 21.0.0, you can optimize SDK initialization and ad loading to enhance ad responsiveness and mitigate ANR errors.\u003c/p\u003e\n"],["\u003cp\u003eThis optimization is achieved through two flags within the Google Mobile Ads settings: "Optimize Initialization" and "Optimize AdLoading", which offload time-consuming tasks to background threads.\u003c/p\u003e\n"],["\u003cp\u003eTo enable these optimizations, you need to update your Google Mobile Ads Unity plugin to version 7.2.0 or higher and adjust the settings via the Unity asset menu (Assets > Google Mobile Ads > Settings).\u003c/p\u003e\n"],["\u003cp\u003eBy default, both optimization flags are set to \u003ccode\u003efalse\u003c/code\u003e, allowing you to selectively enable them based on your app's needs.\u003c/p\u003e\n"]]],[],null,["# Optimize initialization and ad loading\n\nSelect platform: [Android](/ad-manager/mobile-ads-sdk/android/optimize-initialization \"View this page for the Android platform docs.\") [Unity](/ad-manager/mobile-ads-sdk/unity/optimize-initialization \"View this page for the Unity platform docs.\")\n\n\u003cbr /\u003e\n\nStarting from Google Mobile Ads (GMA) SDK version 21.0.0, you can enable\noptimized SDK initialization and ad loading to improve the overall\nresponsiveness of ads and help prevent [\"Application Not Responding\"\n(ANR)](//developer.android.com/topic/performance/vitals/anr) errors on your app.\nThis guide outlines the changes you need to make to enable these optimizations.\n\nRequirements\n------------\n\n- Complete the [Get Started guide](/ad-manager/mobile-ads-sdk/unity/quick-start).\n\n\u003c!-- --\u003e\n\n- Google Mobile Ads Unity plugin version 7.2.0 or higher.\n\nUpdate your Google Mobile Ads settings\n--------------------------------------\n\nThe\n\nGoogle Mobile Ads SDK\n\nenables optimization by default, and instructs the SDK to\nperform initialization and ad loading tasks processing on background threads.\n\nThe following flags are available for the\n\nGoogle Mobile Ads SDK\n\nsettings scriptable\nobject:\n\n- Disable initialization optimization\n- Disable ad loading optimization\n\nCheck these settings to instruct the SDK to initialize and load ads on the main\nthread:\n\n| Setting | Behavior |\n|---------------------------------|-----------------------------------------------------------------------|------------------------------------------|\n| Disable Optimize Initialization | Disables optimizing the `MobileAds.initialize()` initialization call. |\n| Disable ad loading optimization | Optimizes ad load calls for all ad formats. | Disables optimizing the ad loading call. |\n\nYou can access the Google Mobile Ads settings through the Unity asset menu:\n\n**Assets \\\u003e Google Mobile Ads \\\u003e Settings**\n\nOnce selected, the settings UI appears in your Unity Editor inspector window.\n\nNote that you can turn on one or both options in the same app."]]