PlatformUtil.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. using XGame.Framework;
  2. using System;
  3. using UnityEditor;
  4. namespace XGame.Editor.Asset
  5. {
  6. public static class PlatformUtil
  7. {
  8. public static PlatformType ActivePlatform => BuildTargetToPlatformType(EditorUserBuildSettings.activeBuildTarget);
  9. public static PlatformType BuildTargetToPlatformType(BuildTarget target)
  10. {
  11. switch (target)
  12. {
  13. case BuildTarget.StandaloneOSX:
  14. return PlatformType.Mac;
  15. case BuildTarget.StandaloneWindows:
  16. case BuildTarget.StandaloneWindows64:
  17. return PlatformType.Windows;
  18. case BuildTarget.iOS:
  19. return PlatformType.iOS;
  20. case BuildTarget.Android:
  21. return PlatformType.Android;
  22. case BuildTarget.WeixinMiniGame:
  23. return PlatformType.Weixin;
  24. case BuildTarget.WebGL:
  25. return PlatformType.WebGL;
  26. default:
  27. throw new NotImplementedException();
  28. }
  29. }
  30. }
  31. }