Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Troubleshooting an EditMode test

Discussion in 'Scripting' started by AcademyOfFetishes, Jan 10, 2019.

  1. AcademyOfFetishes

    AcademyOfFetishes

    Joined:
    Nov 16, 2018
    Posts:
    219
    TL;DR: Is there a way to pause an EditMode test so I can explore the state of the scene using the UnityEditor?

    Hello, I've got this edit mode test that is not functioning correctly. Here's the assert that fails:

    Code (CSharp):
    1. Assert.IsNotNull(GameObject.Find("Dialog"));
    I have no idea why that game object can't be found. It would probably be very obvious if I could just see the state of the editor right before this assert fails.

    My question is, is there a way to pause an EditMode test so I can explore the state of the scene using the Unity Editor? I tried putting
    Debug.Break()
    and
    Debug.DebugBreak()
    in my tests, but for some reason, this doesn't do anything. I'm using VS Code and I have attached a debugger, but when it hits a breakpoint, the Unity Editor freezes, so I can't explore the state of the scene. I tried putting a
    while (true) {}
    right before the assert, but this freezes the editor, too.

    I'm using C# if that matters. Also, this is a
    [UnityTest]
     
  2. hpjohn

    hpjohn

    Joined:
    Aug 14, 2012
    Posts:
    2,190
    while (true) { yield return null; }
    ?
     
    AcademyOfFetishes likes this.
  3. AcademyOfFetishes

    AcademyOfFetishes

    Joined:
    Nov 16, 2018
    Posts:
    219
    That is really nice! That'll probably be what I need most the time, but it leaves this modal popup:



    That popup prevents me from using the editor. I can't expand the hierarchy or look at the inspector. Is there a way to pause and be able to do that?