Rasagar/Library/PackageCache/com.unity.test-framework/UnityEditor.TestRunner/TestRun/Tasks/EnterPlayModeTask.cs

31 lines
770 B
C#
Raw Normal View History

2024-08-26 13:07:20 -07:00
using System;
using System.Collections;
using UnityEngine;
namespace UnityEditor.TestTools.TestRunner.TestRun.Tasks
{
internal class EnterPlayModeTask : TestTaskBase
{
public Func<bool> IsInPlayMode = () => Application.isPlaying;
public Action EnterPlayMode = () => EditorApplication.isPlaying = true;
public override IEnumerator Execute(TestJobData testJobData)
{
if (IsInPlayMode())
{
yield break;
}
// Give the UI a change to update the progress bar, sa entering playmode freezes.
yield return null;
EnterPlayMode();
while (!IsInPlayMode())
{
yield return null;
}
}
}
}