ドキュメント

Unity Ads Monetization


Unity API reference

Unity Ads Monetization


Initialize the SDK in Unity

Initialize the Unity Ads SDK with your Game ID to enable monetization and access Unity Ads public APIs in your Unity project.
読み終わるまでの所要時間 1 分最終更新 21時間前

重要
If you serve Unity Ads through a mediation partner, such as Unity LevelPlay, Google AdMob, or AppLovin MAX, follow your mediation partner's Unity Ads adapter guide instead of this direct-integration guide. In most cases, the mediation SDK initializes the Unity Ads adapter for you, so calling Unity Ads initialization from your own code risks a duplicate initialization. Install and initialize the Unity Ads SDK yourself only when your mediation partner's adapter documentation tells you to, such as on an open-source adapter path. For more information, refer to Implement Unity Ads in a mediation stack.
重要
You must configure user consent before or during SDK initialization. Serving ads without consent configuration may violate privacy regulations in some regions.
To initialize the SDK, you must reference your project's Game ID for the appropriate platform. You can locate the Game ID from the Unity Ads Monetization dashboard by selecting the Monetization suite, navigating to your current project, then Settings in the secondary navigation bar, and scrolling to the Game IDs section.
注
Starting April 1, 2026, apps that monetize with Unity Ads through direct integration through the Advertisement Legacy Package might see reduced ad performance. To avoid reduction in performance, switch to integrating Unity Ads as a bidder.
The Unity Ads network will continue to support and provide fill for all apps using direct integration. However, to maximize revenue and performance, the recommended best practice is to install the Ads Mediation package for LevelPlay, Unity's ad mediation platform.
In your game script header, include the
UnityEngine.Advertisements
namespace. Initialize the SDK early in the game's run-time life cycle, preferably at launch, using the
Initialize
function. In SDK versions 3.7.0 and later, you can use
IUnityAdsInitializationListener
callbacks to receive a notification when initialization is complete, or receive the details when an error occurs.

SDK initialization example

using UnityEngine;using UnityEngine.Advertisements;public class AdsInitializer : MonoBehaviour, IUnityAdsInitializationListener{ [SerializeField] string _androidGameId; [SerializeField] string _iOSGameId; [SerializeField] bool _testMode = true; private string _gameId; void Awake() { InitializeAds(); } public void InitializeAds() { #if UNITY_IOS _gameId = _iOSGameId; #elif UNITY_ANDROID _gameId = _androidGameId; #elif UNITY_EDITOR _gameId = _androidGameId; //Only for testing the functionality in the Editor #endif if (!Advertisement.isInitialized && Advertisement.isSupported) { Advertisement.Initialize(_gameId, _testMode, this); } } public void OnInitializationComplete() { Debug.Log("Unity Ads initialization complete."); } public void OnInitializationFailed(UnityAdsInitializationError error, string message) { Debug.Log($"Unity Ads Initialization Failed: {error.ToString()} - {message}"); }}
Next steps: To continue your integration, refer to the Implement interstitial ads in Unity documentation.