افزونه Google Mobile Ads Unity به توسعه دهندگان Unity این امکان را می دهد که تبلیغات تلفن همراه Google را در برنامه های Android و iOS بدون نیاز به نوشتن کد جاوا یا Objective-C ارائه دهند. این افزونه یک رابط C# برای درخواست تبلیغات ارائه می دهد که توسط اسکریپت های C# در پروژه Unity شما استفاده می شود.
این راهنما برای ناشرانی در نظر گرفته شده است که میخواهند از برنامه Unity کسب درآمد کنند.
سطح API Android در تنظیمات پروژه > پخش کننده > اندروید > تنظیمات دیگر > تنظیمات دیگر تنظیم شده است.
افزونه Mobile Ads for Unity را وارد کنید
OpenUPM-CLI
اگر OpenUPM CLI را نصب کرده اید، می توانید رجیستری OpenUPM را با دستور زیر نصب کنید:
openupmaddcom.google.ads.mobile
دارایی های افزونه .unitypackage را حذف کنید
اگر از استفاده از .unitypackage به استفاده از OpenUPM مهاجرت می کنید، باید دارایی ها را به صورت دستی از مکان قدیمی حذف کنید. دایرکتوری های زیر را که از .unitypackage وارد شده اند حذف کنید:
منوی مدیریت بسته را با انتخاب گزینه منوی Unity Window > Package Manager باز کنید.
منوی کشویی مدیریت دامنه را برای انتخاب My Registries تنظیم کنید.
بسته Google Mobile Ads for Unity را از لیست بسته انتخاب کنید و Install را فشار دهید.
دارایی های افزونه .unitypackage را حذف کنید
اگر از استفاده از .unitypackage به استفاده از OpenUPM مهاجرت می کنید، باید دارایی ها را به صورت دستی از مکان قدیمی حذف کنید. دایرکتوری های زیر را که از .unitypackage وارد شده اند حذف کنید:
قبل از بارگیری تبلیغات، از برنامه خود بخواهید با فراخوانی MobileAds.Initialize() SDK تبلیغات موبایل Google را مقداردهی اولیه کند. این کار باید فقط یک بار انجام شود، ایده آل در هنگام راه اندازی برنامه.
در اینجا مثالی از نحوه فراخوانی 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});
اگر از میانجیگری استفاده میکنید، منتظر بمانید تا قبل از بارگیری آگهیها، پاسخ تماس رخ دهد تا تأیید کنید که همه آداپتورهای واسطهای اولیه هستند.
یک قالب تبلیغ را انتخاب کنید
Google Mobile Ads SDK اکنون در برنامه Unity شما در هنگام استقرار در پلتفرم Android یا iOS گنجانده شده است. اکنون آماده اجرای یک تبلیغ هستید. AdMob قالبهای مختلف تبلیغاتی را ارائه میدهد، بنابراین میتوانید یکی را انتخاب کنید که بهترین تجربه کاربری را ایجاد میکند.
بنر
واحدهای تبلیغات بنری، تبلیغات مستطیلی را نشان میدهند که بخشی از طرحبندی برنامه را اشغال میکنند. آنها می توانند پس از مدت زمان مشخصی به طور خودکار بازخوانی شوند. این بدان معناست که کاربران یک تبلیغ جدید را در فواصل زمانی منظم مشاهده می کنند، حتی اگر در همان صفحه در برنامه شما بمانند. آنها همچنین ساده ترین قالب تبلیغاتی برای پیاده سازی هستند.
واحدهای تبلیغات بینابینی تبلیغات تمام صفحه را در برنامه شما نشان می دهند. آنها را در وقفه ها و جابجایی های طبیعی در رابط برنامه خود قرار دهید، مانند پس از اتمام سطح در یک برنامه بازی.
تبلیغات بومی تبلیغاتی هستند که در آنها میتوانید نحوه نمایش داراییهایی مانند سرفصلها و فراخوانهای اقدام را در برنامههای خود سفارشی کنید. با طراحی خود تبلیغ، می توانید یک نمایش تبلیغاتی طبیعی و بدون مزاحمت ایجاد کنید که می تواند به تجربه کاربری غنی اضافه کند.
واحدهای تبلیغاتی دارای پاداش، کاربران را قادر میسازد تا برای کسب جوایز درونبرنامهای، مانند سکه، زندگی اضافی یا امتیاز، بازی انجام دهند، نظرسنجی کنند یا ویدیو تماشا کنند. میتوانید پاداشهای مختلفی را برای واحدهای تبلیغاتی مختلف تعیین کنید و مقادیر پاداش و مواردی را که کاربر دریافت کرده است را مشخص کنید.
تاریخ آخرین بهروزرسانی 2025-09-06 بهوقت ساعت هماهنگ جهانی.
[[["درک آسان","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-09-06 بهوقت ساعت هماهنگ جهانی."],[[["\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, with Xcode 15.3 or higher for iOS deployment and a minimum Android API level of 21 for Android deployment.\u003c/p\u003e\n"],["\u003cp\u003eThe plugin can be installed via OpenUPM-CLI, OpenUPM, or by importing a \u003ccode\u003e.unitypackage\u003c/code\u003e from GitHub.\u003c/p\u003e\n"],["\u003cp\u003eBefore loading ads, initialize the Google Mobile Ads SDK by calling \u003ccode\u003eMobileAds.Initialize()\u003c/code\u003e at app launch.\u003c/p\u003e\n"],["\u003cp\u003eAdMob offers various ad formats including banner, interstitial, native, and rewarded, each with implementation guides provided.\u003c/p\u003e\n"]]],["The Google Mobile Ads Unity plugin allows Unity developers to integrate Google mobile ads into Android and iOS apps using C#. Installation requires Unity 2019.4+, specific Xcode/iOS and Android API levels, and the use of OpenUPM or direct GitHub import. Developers must remove old `.unitypackage` assets if migrating. The SDK needs to be initialized with `MobileAds.Initialize()`. Developers can set an Ad Manager app ID and choose from various ad formats such as Banner, Interstitial, Native, and Rewarded ads.\n"],null,["Select platform: [Android](/ad-manager/mobile-ads-sdk/android/quick-start \"View this page for the Android platform docs.\") [iOS](/ad-manager/mobile-ads-sdk/ios/quick-start \"View this page for the iOS platform docs.\") [Unity](/ad-manager/mobile-ads-sdk/unity/quick-start \"View this page for the Unity platform docs.\") [Flutter](/ad-manager/mobile-ads-sdk/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\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\nSet your Ad Manager 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[Ad Manager app ID](//support.google.com/admanager/answer/1656921)\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. Verify 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/9544f919c5c8067939fa38d7fb45d698a7408dc1/samples/HelloWorld/Assets/Scripts/GoogleMobileAdsController.cs#L105-L134\n\nIf you're using mediation, wait until the callback occurs before loading ads to\nverify 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](/ad-manager/mobile-ads-sdk/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](/ad-manager/mobile-ads-sdk/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](/ad-manager/mobile-ads-sdk/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](/ad-manager/mobile-ads-sdk/unity/rewarded)"]]