SW 중심대학 OSS GIT 서버 박건태, 이승준, 고기완, 이준호 새로운 배포
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.

60 lines
2.4 KiB

4 years ago
  1. # Custom yield instructions
  2. By implementing this interface below, you can define custom yield instructions in **Edit Mode** tests.
  3. ## IEditModeTestYieldInstruction
  4. 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:
  5. - [EnterPlayMode](#enterplaymode)
  6. - [ExitPlayMode](#exitplaymode)
  7. - [RecompileScripts](./reference-recompile-scripts.md)
  8. - [WaitForDomainReload](./reference-wait-for-domain-reload.md)
  9. ## Example
  10. ```c#
  11. [UnityTest]
  12. public IEnumerator PlayOnAwakeDisabled_DoesntPlayWhenEnteringPlayMode()
  13. {
  14. var videoPlayer = PrefabUtility.InstantiatePrefab(m_VideoPlayerPrefab.GetComponent<VideoPlayer>()) as VideoPlayer;
  15. videoPlayer.playOnAwake = false;
  16. yield return new EnterPlayMode();
  17. var videoPlayerGO = GameObject.Find(m_VideoPlayerPrefab.name);
  18. Assert.IsFalse(videoPlayerGO.GetComponent<VideoPlayer>().isPlaying);
  19. yield return new ExitPlayMode();
  20. Object.DestroyImmediate(GameObject.Find(m_VideoPlayerPrefab.name));
  21. }
  22. ```
  23. ## Properties
  24. | Syntax | Description |
  25. | ---------------------------- | ------------------------------------------------------------ |
  26. | `bool ExpectDomainReload` | Returns `true` if the instruction expects a domain reload to occur. |
  27. | `bool ExpectedPlaymodeState` | Returns `true` if the instruction expects the Unity Editor to be in **Play Mode**. |
  28. ## Methods
  29. | Syntax | Description |
  30. | ----------------------- | ------------------------------------------------------------ |
  31. | `IEnumerator Perform()` | Used to define multi-frame operations performed when instantiating a yield instruction. |
  32. ## EnterPlayMode
  33. * Implements `IEditModeTestYieldInstruction`. Creates a yield instruction to enter Play Mode.
  34. * When creating an Editor test that uses the `UnityTest` attribute, use this to trigger the Editor to enter Play Mode.
  35. * Throws an exception if the Editor is already in Play Mode or if there is a [script compilation error](https://support.unity3d.com/hc/en-us/articles/205930539-How-do-I-interpret-a-compiler-error-).
  36. ## ExitPlayMode
  37. * Implements `IEditModeTestYieldInstruction`. A new instance of the class is a yield instruction to exit Play Mode.
  38. * Throws an exception if the Editor is not in Play Mode.