using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Advertisements; public class ADManager : MonoBehaviour, IUnityAdsInitializationListener{ [SerializeField] string _androidGameId="5630650"; [SerializeField] string _iOSGameId="5630651"; [SerializeField] bool _testMode = false; private string _gameId; void Awake(){ InitializeAds(); } // Start is called before the first frame update 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}"); } }