PackPlatformBase.cs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. using System.Collections.Generic;
  2. using System;
  3. using System.IO;
  4. using System.Reflection;
  5. using System.Text;
  6. using UnityEngine;
  7. using UnityEditor;
  8. namespace Pack
  9. {
  10. [Serializable]
  11. public partial class PackPlatformBase : IEquatable<PackPlatformBase>, ICloneable
  12. {
  13. public string channelName = "文庭";
  14. public string appName = "仙境归来";
  15. public string distributeName = "无SDK版本";
  16. public string channelUniqueId = "0";
  17. public string bundleId = "com.wt.no.sdk.test";
  18. public VersionCode gameVersionCode = VersionCode.zeroVersionCode;
  19. public VersionCode resVersionCode = VersionCode.zeroVersionCode;
  20. public string iconRelativePath = "Default";
  21. public string GetChannelUniqueName()
  22. {
  23. if (string.IsNullOrEmpty(distributeName))
  24. return GetBuildTarget() + "/" + channelName + "/" + appName;
  25. else
  26. return GetBuildTarget() + "/" + channelName + "/" + appName + "(" + distributeName + ")";
  27. }
  28. protected string GetPackFileName()
  29. {
  30. string packFileName;
  31. if (string.IsNullOrEmpty(distributeName))
  32. packFileName = channelName + "_" + appName;
  33. else
  34. packFileName = channelName + "_" + appName + "(" + distributeName + ")";
  35. packFileName = packFileName.Replace("\\", "_");
  36. packFileName = packFileName.Replace("/", "_");
  37. return packFileName;
  38. }
  39. public virtual bool Equals(PackPlatformBase packPlatform)
  40. {
  41. if (packPlatform == null)
  42. return false;
  43. if (GetType() != packPlatform.GetType())
  44. return false;
  45. // 由于是编辑环境,暂时这么处理,效率并不高
  46. string contentStr1 = JsonUtility.ToJson(this);
  47. string contentStr2 = JsonUtility.ToJson(packPlatform);
  48. return (contentStr1 == contentStr2);
  49. }
  50. public virtual object Clone()
  51. {
  52. // 由于是编辑环境,暂时这么处理,效率并不高
  53. string contentStr = JsonUtility.ToJson(this);
  54. return JsonUtility.FromJson(contentStr, GetType());
  55. }
  56. }
  57. }