By implementing this interface below, you can define custom yield instructions in Edit Mode tests.
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:
[UnityTest]
public IEnumerator PlayOnAwakeDisabled_DoesntPlayWhenEnteringPlayMode()
{
var videoPlayer = PrefabUtility.InstantiatePrefab(m_VideoPlayerPrefab.GetComponent<VideoPlayer>()) as VideoPlayer;
videoPlayer.playOnAwake = false;
yield return new EnterPlayMode();
var videoPlayerGO = GameObject.Find(m_VideoPlayerPrefab.name);
Assert.IsFalse(videoPlayerGO.GetComponent<VideoPlayer>().isPlaying);
yield return new ExitPlayMode();
Object.DestroyImmediate(GameObject.Find(m_VideoPlayerPrefab.name));
}
Syntax | Description |
---|---|
bool ExpectDomainReload |
Returns true if the instruction expects a domain reload to occur. |
bool ExpectedPlaymodeState |
Returns true if the instruction expects the Unity Editor to be in Play Mode. |
Syntax | Description |
---|---|
IEnumerator Perform() |
Used to define multi-frame operations performed when instantiating a yield instruction. |
IEditModeTestYieldInstruction
. Creates a yield instruction to enter Play Mode.UnityTest
attribute, use this to trigger the Editor to enter Play Mode.IEditModeTestYieldInstruction
. A new instance of the class is a yield instruction to exit Play Mode.