MonoBehaviourTest.cs 706 B

1234567891011121314151617181920212223
  1. namespace UnityEngine.TestTools
  2. {
  3. public class MonoBehaviourTest<T> : CustomYieldInstruction where T : MonoBehaviour, IMonoBehaviourTest
  4. {
  5. public T component { get; }
  6. public GameObject gameObject { get { return component.gameObject; } }
  7. public MonoBehaviourTest(bool dontDestroyOnLoad = true)
  8. {
  9. var go = new GameObject("MonoBehaviourTest: " + typeof(T).FullName);
  10. component = go.AddComponent<T>();
  11. if (dontDestroyOnLoad)
  12. {
  13. Object.DontDestroyOnLoad(go);
  14. }
  15. }
  16. public override bool keepWaiting
  17. {
  18. get { return !component.IsTestFinished; }
  19. }
  20. }
  21. }