暫無描述
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

IEditModeTestYieldInstruction.cs 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. using System;
  2. using System.Collections;
  3. namespace UnityEngine.TestTools
  4. {
  5. /// <summary>
  6. /// In an Edit Mode test, you can use `IEditModeTestYieldInstruction` interface to implement your own instruction. There are also a couple of commonly used implementations available:
  7. /// - <see cref = "EnterPlayMode"/>
  8. /// - <see cref = "ExitPlayMode"/>
  9. /// - <see cref = "RecompileScripts"/>
  10. /// - <see cref = "WaitForDomainReload"/>
  11. /// </summary>
  12. /// <example>
  13. /// <code>
  14. /// <![CDATA[
  15. /// [UnityTest]
  16. /// public IEnumerator PlayOnAwakeDisabled_DoesntPlayWhenEnteringPlayMode()
  17. /// {
  18. /// var videoPlayer = PrefabUtility.InstantiatePrefab(m_VideoPlayerPrefab.GetComponent<VideoPlayer>()) as VideoPlayer;
  19. ///
  20. /// videoPlayer.playOnAwake = false;
  21. ///
  22. /// yield return new EnterPlayMode();
  23. ///
  24. /// var videoPlayerGO = GameObject.Find(m_VideoPlayerPrefab.name);
  25. ///
  26. /// Assert.IsFalse(videoPlayerGO.GetComponent<VideoPlayer>().isPlaying);
  27. ///
  28. /// yield return new ExitPlayMode();
  29. ///
  30. /// Object.DestroyImmediate(GameObject.Find(m_VideoPlayerPrefab.name));
  31. /// }
  32. /// ]]>
  33. /// </code>
  34. /// </example>
  35. public interface IEditModeTestYieldInstruction
  36. {
  37. /// <summary>
  38. /// Whether or not the instruction expects a domain reload to occur.
  39. /// </summary>
  40. bool ExpectDomainReload { get; }
  41. /// <summary>
  42. /// Whether or not the instruction expects the Unity Editor to be in **Play Mode**.
  43. /// </summary>
  44. bool ExpectedPlaymodeState { get; }
  45. /// <summary>
  46. /// Used to define multi-frame operations performed when instantiating a yield instruction.
  47. /// </summary>
  48. /// <returns>Enumerable collection of operations to perform.</returns>
  49. IEnumerator Perform();
  50. }
  51. }