'Unity scene objects missing from hierarchy whilst running a play-mode test
I'm having some issues with my scene and objects not loading as I'd expect during a play-mode test in Unity, and I'm hoping that somebody could help me diagnose this.
I have a simple scene with some objects such as Text and InputField, and after clicking play manually, these can be interacted with, and seen in all their glory via the hierarchy like so:
Hierarchy after clicking Play manually
However, if I then go and run my play-mode test, the same scene doesn't appear to be loaded, instead the hierarchy pane shows "InitTestScene[LongStringOfNumbers]" with just one object called "Code-based tests runner", like so:
Hierarchy during play-mode test
This is then causing NullReferenceExceptions during my tests, because I'm attempting to find objects called "InputField (TMP)", which doesn't exist in the hierarchy, and my test is blowing up as a result.
At first I thought maybe I had to load this scene as part of the setup of the test, so I tried SceneManager.LoadScene("MyScene", LoadSceneMode.Single); but to no avail.
Any ideas how to overcome this, so that my play-mode tests are utilising a hierarchy representative of the first screenshot I posted, as opposed to the second screenshot which is missing all the objects?
Thanks
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
