对初始化和广告加载过程进行优化
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
从 Google 移动广告 (GMA) SDK 21.0.0 版开始,您可以启用优化型 SDK 初始化和广告加载功能,以提高广告的整体响应速度,并帮助防止应用出现“应用无响应”(ANR) 错误。本指南简要说明了需要做出哪些更改才能启用这些优化功能。
要求
- Google 移动广告 Unity 插件 7.2.0 版或更高版本。
更新 Google 移动广告设置
Google 移动广告 SDK 默认启用优化功能,并会指示 SDK 在后台线程中处理初始化和广告加载任务。
以下标志可用于 Google 移动广告 SDK 设置的可脚本化对象:
如果要指示 SDK 在主线程中初始化和加载广告,请参考以下设置:
设置 | 行为 |
停用初始化优化 |
停用优化 MobileAds.initialize() 初始化调用的功能。 |
停用广告加载优化
|
为所有广告格式优化广告加载调用。 |
停用优化广告加载调用的功能。 |
您可以通过以下 Unity 资源菜单访问 Google 移动广告设置:
“Assets”(资源)>“Google Mobile Ads”(Google 移动广告)>“Settings”(设置)
选择后,设置界面会显示在 Unity 编辑器的检查器窗口中。

请注意,您可以在同一应用中启用其中一个或同时启用两个选项。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-28。
[null,null,["最后更新时间 (UTC):2025-08-28。"],[[["\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\u003eThese optimizations are enabled through two flags within the Google Mobile Ads settings: \u003cstrong\u003eOptimize Initialization\u003c/strong\u003e and \u003cstrong\u003eOptimize AdLoading\u003c/strong\u003e, which offload time-consuming tasks to background threads.\u003c/p\u003e\n"],["\u003cp\u003eYou can access and modify these settings via the Unity asset menu: \u003cstrong\u003eAssets > Google Mobile Ads > Settings\u003c/strong\u003e, enabling either or both options based on your needs.\u003c/p\u003e\n"],["\u003cp\u003eBy default, both optimization flags are set to \u003ccode\u003efalse\u003c/code\u003e, requiring you to manually enable them to leverage these improvements.\u003c/p\u003e\n"]]],["Optimized SDK initialization and ad loading can be enabled in Google Mobile Ads (GMA) SDK version 21.0.0 and higher, preventing \"Application Not Responding\" (ANR) errors. To activate, update to Google Mobile Ads Unity plugin version 7.2.0 or higher. In Unity's **Assets \u003e Google Mobile Ads \u003e Settings**, enable **Optimize Initialization** and/or **Optimize AdLoading**. These settings offload initialization and ad loading to background threads. Both flags are `false` by default.\n"],null,["# Optimize initialization and ad loading\n\nSelect platform: [Android](/admob/android/optimize-initialization \"View this page for the Android platform docs.\") [Unity](/admob/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](/admob/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."]]