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.

BuildPreProcessor.cs 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. using System;
  2. using System.IO;
  3. using UnityEditor;
  4. using UnityEngine;
  5. using UnityEditor.Build;
  6. #if UNITY_2018_1_OR_NEWER
  7. using UnityEditor.Build.Reporting;
  8. #endif
  9. using UnityEditor.Callbacks;
  10. using GoogleMobileAds.Editor;
  11. #if UNITY_2018_1_OR_NEWER
  12. public class BuildPreProcessor : IPreprocessBuildWithReport
  13. #else
  14. public class BuildPreProcessor : IPreprocessBuild
  15. #endif
  16. {
  17. public int callbackOrder { get { return 1; } }
  18. #if UNITY_2018_1_OR_NEWER
  19. public void OnPreprocessBuild(BuildReport report)
  20. #else
  21. public void OnPreprocessBuild(BuildTarget target, string path)
  22. #endif
  23. {
  24. if (!AssetDatabase.IsValidFolder("Assets/GoogleMobileAds"))
  25. {
  26. AssetDatabase.CreateFolder("Assets", "GoogleMobileAds");
  27. }
  28. /*
  29. * Handle importing GMA via Unity Package Manager.
  30. */
  31. EditorPathUtils pathUtils = ScriptableObject.CreateInstance<EditorPathUtils>();
  32. if (pathUtils.IsPackageRootPath())
  33. {
  34. string parentDirectoryPath = pathUtils.GetParentDirectoryAssetPath();
  35. string linkXmlPath = Path.Combine(parentDirectoryPath, "link.xml");
  36. /*
  37. * Copy link.xml to Assets/GoogleMobileAds to ensure all platform dependent libraries
  38. * are included in the build.
  39. */
  40. AssetDatabase.CopyAsset(linkXmlPath, "Assets/GoogleMobileAds/link.xml");
  41. }
  42. }
  43. }