広告を読み込む前に、MobileAds.Initialize() を呼び出して、アプリで Google Mobile Ads SDK を初期化します。この処理は 1 回だけ行います(アプリの起動時に行うのが理想的です)。
MobileAds.Initialize() を呼び出す方法の例を次に示します。
MobileAds.Initialize((InitializationStatusinitstatus)=> {if(initstatus==null){Debug.LogError("Google Mobile Ads initialization failed.");return;}Debug.Log("Google Mobile Ads initialization complete.");// Google Mobile Ads events are raised off the Unity Main thread. If you need to// access UnityEngine objects after initialization,// use MobileAdsEventExecutor.ExecuteInUpdate(). For more information, see:// https://developers.google.com/admob/unity/global-settings#raise_ad_events_on_the_unity_main_thread});
[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["必要な情報がない","missingTheInformationINeed","thumb-down"],["複雑すぎる / 手順が多すぎる","tooComplicatedTooManySteps","thumb-down"],["最新ではない","outOfDate","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["サンプル / コードに問題がある","samplesCodeIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2025-08-22 UTC。"],[[["\u003cp\u003eThe Google Mobile Ads Unity plugin allows Unity developers to integrate Google mobile ads into Android and iOS apps without writing Java or Objective-C.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers must use Unity 2019.4 or higher, along with specific Xcode and Android requirements for iOS and Android deployments, respectively.\u003c/p\u003e\n"],["\u003cp\u003eThe plugin can be imported using OpenUPM-CLI, OpenUPM, or GitHub, with instructions for each method provided.\u003c/p\u003e\n"],["\u003cp\u003eBefore loading ads, initialize the Google Mobile Ads SDK by calling \u003ccode\u003eMobileAds.Initialize()\u003c/code\u003e once at app launch, and select from various ad formats like Banner, Interstitial, Native, Rewarded, Rewarded Interstitial, and App Open.\u003c/p\u003e\n"],["\u003cp\u003eThe plugin utilizes the Unity Play Services Resolver library for dependency management, which requires specific steps for Android and iOS to ensure all dependencies are included.\u003c/p\u003e\n"]]],["The Google Mobile Ads Unity plugin enables Unity developers to integrate Google mobile ads into Android and iOS apps using C#. Key actions include: setting up prerequisites (Unity version, API levels, Xcode, CocoaPods), installing the plugin via OpenUPM or GitHub, and removing old `.unitypackage` assets. You will need to include external dependencies, and resolve Android dependencies. The next step is to enter your AdMob app ID in settings, initialize the SDK with `MobileAds.Initialize()`, then select and implement an ad format (banner, interstitial, native, rewarded, rewarded interstitial, app open).\n"],null,["Select platform: [Android](/admob/android/quick-start \"View this page for the Android platform docs.\") [iOS](/admob/ios/quick-start \"View this page for the iOS platform docs.\") [Unity](/admob/unity/quick-start \"View this page for the Unity platform docs.\") [Flutter](/admob/flutter/quick-start \"View this page for the Flutter platform docs.\")\n\n\u003cbr /\u003e\n\nThe Google Mobile Ads Unity plugin lets Unity developers serve Google mobile ads\non Android and iOS apps without having to write Java or Objective-C code. The\nplugin provides a C# interface for requesting ads that is used by C# scripts in\nyour Unity project.\n\nThis guide is intended for publishers who want to monetize a Unity app.\n\nPrerequisites\n\n- Use Unity Editor 2019.4 or higher\n- To deploy to iOS\n - Xcode 16.0 or higher\n - Target iOS 12.0 or higher\n - [CocoaPods](//guides.cocoapods.org/using/getting-started.html)\n- To deploy to Android\n - Minimum Android API level of 23 or higher\n - Target Android API level 34 or higher\n\n\u003c!-- --\u003e\n\n- Recommended: [Create an AdMob\n account](//support.google.com/admob/answer/2784575) and [register an\n Android or iOS app](//support.google.com/admob/answer/2773509)\n\nAndroid API level is set in **Project Settings \\\u003e Player \\\u003e\nAndroid \\\u003e Other Settings \\\u003e Other Settings**.\n\nImport the Mobile Ads for Unity plugin \n\nOpenUPM-CLI\n\nIf you have the [OpenUPM CLI](//github.com/openupm/openupm-cli#installation)\ninstalled, you can install the OpenUPM registry with the following\ncommand: \n\n openupm add com.google.ads.mobile\n\n\nRemove `.unitypackage` plugin assets\n\nIf you are migrating from using a `.unitypackage` to using OpenUPM, you\nmust manually uninstall the assets from the old location. Remove the\nfollowing directories that were imported from the `.unitypackage`:\n\n- Assets/ExternalDependencyManager\n- Assets/GoogleMobileAds\n- Assets/Plugins/Android/googlemobileads-unity.aar\n- Assets/Plugins/Android/GoogleMobileAdsPlugin\n- Assets/Plugins/iOS/GADUAdNetworkExtras\n- Assets/Plugins/iOS/unity-plugin-library.a \u003cbr /\u003e\n\nOpenUPM\n\n1. Open the [package manager settings](//docs.unity3d.com/Manual/class-PackageManager.html) by selecting the Unity menu option **Edit \\\u003e Project Settings \\\u003e Package Manager**.\n2. Add OpenUPM as a scoped registry to the Package Manager window:\n\n Name: OpenUPM\n URL: https://package.openupm.com\n Scopes: com.google\n\n3. Open the [package manager menu](//docs.unity3d.com/Manual/upm-ui-install.html) by selecting the Unity\n menu option **Window \\\u003e Package Manager**.\n\n4. Set the manager scope drop-down to select **My Registries**.\n\n5. Select the **Google Mobile Ads for Unity** package from the package list\n and press **Install**.\n\n\nRemove `.unitypackage` plugin assets\n\nIf you are migrating from using a `.unitypackage` to using OpenUPM, you\nmust manually uninstall the assets from the old location. Remove the\nfollowing directories that were imported from the `.unitypackage`:\n\n- Assets/ExternalDependencyManager\n- Assets/GoogleMobileAds\n- Assets/Plugins/Android/googlemobileads-unity.aar\n- Assets/Plugins/Android/GoogleMobileAdsPlugin\n- Assets/Plugins/iOS/GADUAdNetworkExtras\n- Assets/Plugins/iOS/unity-plugin-library.a \u003cbr /\u003e\n\nImport from GitHub\n\n1. Download the latest [`.unitypackage`](//github.com/googleads/googleads-mobile-unity/releases/latest) release from GitHub.\n2. Import the `.unitypackage` file by selecting the Unity menu option **Assets \\\u003e Import package \\\u003e Custom Package** and importing all items.\n\nInclude external dependencies\n\nThe Google Mobile Ads Unity plugin is distributed with the [Unity Play Services\nResolver library](//github.com/googlesamples/unity-jar-resolver). This library\nis intended for use by any Unity plugin that requires access to Android-specific\nlibraries, such as AARs, or iOS CocoaPods. It provides Unity plugins the ability\nto declare dependencies, which are then automatically resolved and copied into\nyour Unity project.\n\n\n| **Important:** Use the latest Google Mobile Ads SDK so that you have access to all the privacy compliance features.\n\n\u003cbr /\u003e\n\nFollow these steps to ensure that your project includes all the dependencies: \n\nAndroid\n\nGo to **Project Settings \\\u003e Player \\\u003e Android \\\u003e Publishing Settings \\\u003e Build**\nand select:\n\n- Custom Main Gradle Template\n- Custom Gradle Properties Template\n\nIn the Unity editor, select **Assets \\\u003e External Dependency Manager \\\u003e Android\nResolver \\\u003e Resolve** to have the Unity External Dependency Manager library\ncopy the declared dependencies into the `Assets/Plugins/Android` directory\nof your Unity app.\n\niOS\n\nUnity for iOS uses CocoaPods to identify and manage dependencies.\nConsult the [CocoaPods documentation](https://guides.cocoapods.org/) for\nspecific requirements or troubleshooting steps related to your iOS\ndependencies.\n\nThe Google Mobile Ads Unity plugin dependencies are listed in\n`Assets/GoogleMobileAds/Editor/GoogleMobileAdsDependencies.xml`.\n\nSet your AdMob app ID\n\nIn the Unity editor, select **Assets \\\u003e Google Mobile Ads \\\u003e Settings**\nfrom the menu.\n\nEnter your Android and iOS\n\n[AdMob app ID](//support.google.com/admob/answer/6232340)\n\nin each field.\n\nInitialize the SDK\n\nBefore loading ads, have your app initialize the Google Mobile Ads SDK by\ncalling `MobileAds.Initialize()`. This needs to be done only once, ideally at\napp launch.\n| **Warning:** Ads can be preloaded by the Google Mobile Ads SDK or mediation partner SDKs upon calling `MobileAds.Initialize()`. If you need to obtain consent from users in the European Economic Area (EEA), set any request-specific flags, such as `tagForChildDirectedTreatment` or `tag_for_under_age_of_consent`, or otherwise take action before loading ads. Ensure you do this before initializing the Google Mobile Ads SDK.\n\nHere's an example of how to call `MobileAds.Initialize()`: \n\n MobileAds.Initialize((InitializationStatus initstatus) =\u003e\n {\n if (initstatus == null)\n {\n Debug.LogError(\"Google Mobile Ads initialization failed.\");\n return;\n }\n\n Debug.Log(\"Google Mobile Ads initialization complete.\");\n\n // Google Mobile Ads events are raised off the Unity Main thread. If you need to\n // access UnityEngine objects after initialization,\n // use MobileAdsEventExecutor.ExecuteInUpdate(). For more information, see:\n // https://developers.google.com/admob/unity/global-settings#raise_ad_events_on_the_unity_main_thread\n }); \n https://github.com/googleads/googleads-mobile-unity/blob/ed5c6785869ea71c6ce397e0fbce7e6106227093/samples/HelloWorld/Assets/Scripts/GoogleMobileAdsController.cs#L105-L134\n\nIf you're using mediation, wait until the callback occurs before loading ads to\nensure that all mediation adapters are initialized.\n\nSelect an ad format\n\nThe Google Mobile Ads SDK is now included in your Unity app when deploying to\neither the Android or iOS platform. You're now ready to implement an ad. AdMob\noffers a number of different ad formats, so you can choose the one that makes\nfor the best user experience.\n\nBanner\n\nBanner ad units display rectangular ads that occupy a portion of an app's\nlayout. They can refresh automatically after a set period of time. This means\nusers view a new ad at regular intervals, even if they stay on the same\nscreen in your app. They're also the simplest ad format to implement. \n\n[Implement banner ads](/admob/unity/banner)\n\nInterstitial\n\nInterstitial ad units show full-page ads in your app. Place them at natural\nbreaks and transitions in your app's interface, such as after level completion\nin a gaming app. \n\n[Implement interstitial ads](/admob/unity/interstitial)\n\nNative\n\nNative ads are ads where you can customize the way assets such as headlines and\ncalls to action are presented in your apps. By styling the ad yourself, you can\ncreate a natural, unobtrusive ad presentations that can add to a rich user\nexperience. \n\n[Implement native ads](/admob/unity/native)\n\nRewarded\n\nRewarded ad units enable users to play games, take surveys, or watch videos to\nearn in-app rewards, such as coins, extra lives, or points. You can set\ndifferent rewards for different ad units, and specify the reward values and\nitems the user received. \n\n[Implement rewarded ads](/admob/unity/rewarded)\n\nRewarded interstitial\n\nRewarded interstitial is a new type of incentivized ad format that lets you\noffer rewards, such as coins or extra lives, for ads that appear automatically\nduring natural app transitions.\n\nUnlike rewarded ads, users aren't required to opt in to view a rewarded\ninterstitial.\n\nInstead of the opt-in prompt in rewarded ads, rewarded interstitials require an\nintro screen that announces the reward and gives users a chance to opt out if\nthey want to do so. \n\n[Implement rewarded interstitial ads](/admob/unity/rewarded-interstitial)\n\nApp open\n\nApp open is an ad format that appears when users open or switch back to your\napp. The ad overlays the loading screen. \n\n[Implement app open ads](/admob/unity/app-open)"]]