No Description
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.

GoogleMobileAdsSettings.cs 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. using System;
  2. using System.IO;
  3. using UnityEditor;
  4. using UnityEngine;
  5. namespace GoogleMobileAds.Editor
  6. {
  7. internal class GoogleMobileAdsSettings : ScriptableObject
  8. {
  9. private const string MobileAdsSettingsResDir = "Assets/GoogleMobileAds/Resources";
  10. private const string MobileAdsSettingsFile = "GoogleMobileAdsSettings";
  11. private const string MobileAdsSettingsFileExtension = ".asset";
  12. internal static GoogleMobileAdsSettings LoadInstance()
  13. {
  14. //Read from resources.
  15. var instance = Resources.Load<GoogleMobileAdsSettings>(MobileAdsSettingsFile);
  16. //Create instance if null.
  17. if (instance == null)
  18. {
  19. Directory.CreateDirectory(MobileAdsSettingsResDir);
  20. instance = ScriptableObject.CreateInstance<GoogleMobileAdsSettings>();
  21. string assetPath = Path.Combine(
  22. MobileAdsSettingsResDir,
  23. MobileAdsSettingsFile + MobileAdsSettingsFileExtension);
  24. AssetDatabase.CreateAsset(instance, assetPath);
  25. AssetDatabase.SaveAssets();
  26. Version agp = Version.Parse(Utils.AndroidGradlePluginVersion);
  27. instance.validateGradleDependencies = true;
  28. // Turn on Gradle Dependency Validation if AGP < 4.2.2
  29. if (agp.Major > 4 || (agp.Major == 4 && agp.Minor >= 2 && agp.Build >= 2))
  30. {
  31. instance.validateGradleDependencies = false;
  32. }
  33. }
  34. return instance;
  35. }
  36. [SerializeField]
  37. private string adMobAndroidAppId = string.Empty;
  38. [SerializeField]
  39. private string adMobIOSAppId = string.Empty;
  40. [SerializeField]
  41. private bool enableKotlinXCoroutinesPackagingOption = true;
  42. [SerializeField]
  43. private bool optimizeInitialization;
  44. [SerializeField]
  45. private bool optimizeAdLoading;
  46. [SerializeField]
  47. private string userTrackingUsageDescription;
  48. [SerializeField]
  49. private bool validateGradleDependencies;
  50. public string GoogleMobileAdsAndroidAppId
  51. {
  52. get { return adMobAndroidAppId; }
  53. set { adMobAndroidAppId = value; }
  54. }
  55. public bool EnableKotlinXCoroutinesPackagingOption
  56. {
  57. get { return enableKotlinXCoroutinesPackagingOption; }
  58. set { enableKotlinXCoroutinesPackagingOption = value; }
  59. }
  60. public string GoogleMobileAdsIOSAppId
  61. {
  62. get { return adMobIOSAppId; }
  63. set { adMobIOSAppId = value; }
  64. }
  65. public bool OptimizeInitialization
  66. {
  67. get { return optimizeInitialization; }
  68. set { optimizeInitialization = value; }
  69. }
  70. public bool OptimizeAdLoading
  71. {
  72. get { return optimizeAdLoading; }
  73. set { optimizeAdLoading = value; }
  74. }
  75. public string UserTrackingUsageDescription
  76. {
  77. get { return userTrackingUsageDescription; }
  78. set { userTrackingUsageDescription = value; }
  79. }
  80. public bool ValidateGradleDependencies
  81. {
  82. get { return validateGradleDependencies; }
  83. set { validateGradleDependencies = value; }
  84. }
  85. }
  86. }