VersionUtil.cs 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. using System.Collections;
  2. using UnityEngine;
  3. namespace GFGGame
  4. {
  5. public class VersionUtil
  6. {
  7. /// <summary>
  8. /// 比较目标版本号是否比当前的大
  9. /// </summary>
  10. /// <param name="vCurrent"></param>
  11. /// <param name="vTarget"></param>
  12. /// <returns></returns>
  13. public static bool compare(string vCurrent, string vTarget)
  14. {
  15. string[] infoTarget = vTarget.Split('.');
  16. string[] infoCurrent = vCurrent.Split('.');
  17. if(infoTarget.Length == infoCurrent.Length)
  18. {
  19. for(int i = 0; i < infoCurrent.Length; ++i)
  20. {
  21. if (int.Parse(infoTarget[i]) > int.Parse(infoCurrent[i]))
  22. {
  23. return true;
  24. }
  25. else if (int.Parse(infoTarget[i]) < int.Parse(infoCurrent[i]))
  26. {
  27. return false;
  28. }
  29. }
  30. }
  31. return false;
  32. }
  33. }
  34. }