CmdSwitchPlatform.cs 857 B

12345678910111213141516171819202122232425
  1. using UnityEditor;
  2. namespace XGame.Editor.Build
  3. {
  4. [BuildCommand((uint)BuildCommandPriority.SwitchPlatform)]
  5. internal class CmdSwitchPlatform : BaseBuildCommand, ICommandExecuterAsync
  6. {
  7. public void Execute()
  8. {
  9. BuildLog.Log("CmdSwitchPlatform Execute.");
  10. var target = Context.config.target;
  11. if (EditorUserBuildSettings.activeBuildTarget != target)
  12. {
  13. BuildCompileEvent.RegistEvent(Context);
  14. var targetGroup = target.ToTargetGroup();
  15. BuildLog.Log($"Switch Platform Current:{EditorUserBuildSettings.activeBuildTarget} Target:{target}");
  16. EditorUserBuildSettings.SwitchActiveBuildTarget(targetGroup, target);
  17. }
  18. else
  19. {
  20. this.Completed();
  21. }
  22. }
  23. }
  24. }