ExitPlayMode.cs 799 B

1234567891011121314151617181920212223242526272829303132
  1. using System;
  2. using System.Collections;
  3. using UnityEditor;
  4. namespace UnityEngine.TestTools
  5. {
  6. public class ExitPlayMode : IEditModeTestYieldInstruction
  7. {
  8. public bool ExpectDomainReload { get; }
  9. public bool ExpectedPlaymodeState { get; private set; }
  10. public ExitPlayMode()
  11. {
  12. ExpectDomainReload = false;
  13. ExpectedPlaymodeState = false;
  14. }
  15. public IEnumerator Perform()
  16. {
  17. if (!EditorApplication.isPlayingOrWillChangePlaymode)
  18. {
  19. throw new Exception("Editor is already in EditMode");
  20. }
  21. EditorApplication.isPlaying = false;
  22. while (EditorApplication.isPlaying)
  23. {
  24. yield return null;
  25. }
  26. }
  27. }
  28. }