Sin descripción
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.Advertisements;
  5. public class ADManager : MonoBehaviour, IUnityAdsInitializationListener{
  6. [SerializeField] string _androidGameId="5630650";
  7. [SerializeField] string _iOSGameId="5630651";
  8. [SerializeField] bool _testMode = false;
  9. private string _gameId;
  10. void Awake(){
  11. InitializeAds();
  12. }
  13. // Start is called before the first frame update
  14. public void InitializeAds(){
  15. #if UNITY_IOS
  16. _gameId = _iOSGameId;
  17. #elif UNITY_ANDROID
  18. _gameId = _androidGameId;
  19. #elif UNITY_EDITOR
  20. _gameId = _androidGameId; //Only for testing the functionality in the Editor
  21. #endif
  22. if (!Advertisement.isInitialized && Advertisement.isSupported){
  23. Advertisement.Initialize(_gameId, _testMode, this);
  24. }
  25. }
  26. public void OnInitializationComplete(){
  27. Debug.Log("Unity Ads initialization complete.");
  28. }
  29. public void OnInitializationFailed(UnityAdsInitializationError error, string message){
  30. Debug.Log($"Unity Ads Initialization Failed: {error.ToString()} - {message}");
  31. }
  32. }