- Home /
PlayMode Test - Loading Scenes
So I am just starting out using Unity's PlayMode tests to test my game. I have managed to create some simple tests where I load in some of my game objects and call appropriate functions and assertions upon them. What I would like to do is to be able to load a scene I've built, and run tests from within that scene. For example, I want to be able to load a test scene I've made with objects and collider triggers, but also to load a UI scene from within my game and check everything from within there. Surely I don't have to recreate the scene again from writing code alone? Can somebody advice me on how to do this? I have tried and successfully loaded the scene, however the script then fails to find any of the game objects in that scene. Thanks for any help :)
So to clarify, you have both scenes made, and saved separately?
Correct. I have two scene files in which I want to run Play$$anonymous$$ode tests within
Did you load the second scene asynchronously?
Answer by CyberGW · Dec 10, 2017 at 12:42 PM
OK so thanks to @RocketFriday prompting me I have managed to find the issue. Problem was the the scene is loaded at the next frame, so I needed to add a yield return null between loading the scene and trying to find the game objects. Thought I'd post here to say thanks to Rocket for the help and in case anyone else has the issue.
Your answer
![](https://koobas.hobune.stream/wayback/20220612144319im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
test scene turns all other windows black but game/scene 0 Answers
Play Mode Unit Tests prevent game build succeeding,PlayMode Unit Tests prevent my game from building 1 Answer
Can we create playmode tests outside of the main build assembly? 0 Answers
The type or namespace name `SceneManagment' does not exist in the namespace 1 Answer
The scene is opposite when in play mode,The scene moves from one side to other 0 Answers