PackPlatformAndroidBuild.cs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. using System;
  2. using System.IO;
  3. using System.Text;
  4. using UnityEngine;
  5. using UnityEditor;
  6. namespace Pack
  7. {
  8. public partial class PackPlatformAndroid
  9. {
  10. public override void BuildClear()
  11. {
  12. base.BuildClear();
  13. DeleteDirectoryAssets(Path.GetFullPath(Application.dataPath + PackConstant.PluginAndroidDestPath), true);
  14. DeleteDirectoryAssets(Path.GetFullPath(Application.dataPath + PackConstant.SDKBridgeDestPath), true);
  15. }
  16. protected override void ChangePlayerSettings()
  17. {
  18. base.ChangePlayerSettings();
  19. PlayerSettings.bundleVersion = gameVersionCode;
  20. PlayerSettings.Android.bundleVersionCode = (int)(uint)gameVersionCode;
  21. EditorUserBuildSettings.androidBuildSubtarget = MobileTextureSubtarget.ETC;
  22. PlayerSettings.Android.keystoreName = Application.dataPath + PackConstant.KeyStorePath + keystoreName;
  23. PlayerSettings.Android.keystorePass = keystorePass;
  24. PlayerSettings.Android.keyaliasName = keyaliasName;
  25. PlayerSettings.Android.keyaliasPass = keyaliasPass;
  26. }
  27. protected override void ChangePlatformSpecial()
  28. {
  29. base.ChangePlatformSpecial();
  30. EditorUtility.DisplayProgressBar("平台特殊设置", "开始平台特殊设置", 0);
  31. if (plugins != null && plugins.Count > 0)
  32. {
  33. CopyUnityAssets(Application.dataPath + PackConstant.PluginAndroidSrcPath
  34. , plugins
  35. , Application.dataPath + PackConstant.PluginAndroidDestPath
  36. , Application.dataPath + PackConstant.PluginAndroidSrcMetaPath
  37. , Application.dataPath + PackConstant.PluginAndroidDestMetaPath);
  38. if (!string.IsNullOrEmpty(plugins.Find((x)=>x.StartsWith("Lebian"))))
  39. {
  40. string lebianCustPath = Path.GetFullPath(Application.dataPath + PackConstant.PluginAndroidDestPath + "lebian/lebian_cust.gradle");
  41. if (!File.Exists(lebianCustPath))
  42. {
  43. throw new Exception("找不到乐变自定义文件" + lebianCustPath);
  44. }
  45. string content = File.ReadAllText(lebianCustPath);
  46. content = content.Replace("${MainChId}", leBian_MainChId);
  47. content = content.Replace("${ClientChId}", leBian_ClientChId);
  48. content = content.Replace("${LEBIAN_SECID}", leBian_SECID);
  49. content = content.Replace("${LEBIAN_VERCODE}", ((uint)resVersionCode).ToString());
  50. File.WriteAllText(lebianCustPath, content);
  51. }
  52. }
  53. EditorUtility.DisplayProgressBar("平台特殊设置", "平台特殊设置", 0.5f);
  54. if (sdkBridges != null && sdkBridges.Count > 0)
  55. {
  56. CopyUnityAssets(Application.dataPath + PackConstant.SDKBridgeSrcPath
  57. , sdkBridges
  58. , Application.dataPath + PackConstant.SDKBridgeDestPath
  59. , Application.dataPath + PackConstant.SDKBridgeSrcMetaPath
  60. , Application.dataPath + PackConstant.SDKBridgeDestMetaPath);
  61. }
  62. EditorUtility.DisplayProgressBar("平台特殊设置", "完成平台特殊设置", 1);
  63. }
  64. }
  65. }