- Home /
The question is answered, right answer was accepted
Awake() and Start() function does not get called for PlayMode tests
Hi, I am setting up Play Mode tests in Unity for our project. I want a bunch of code to be executed for my test on Awake() function, but it turns out the Awake() never gets called when the tests run. I am aware the Awake() and Start() functions don't get executed for Edit Mode tests, but I am experiencing this issue for Play Mode tests which is unusual. Can someone help me this issue? Thanks.
Hi. As EDevJogos mentioned, you need to add the scripts to an active gameobject from your scene. Make sure the object is active.
did you put a debug log in the Awake and Start methods to make sure they are not being called?
Answer by dinesh_unity · May 24, 2021 at 11:32 PM
Thanks guys, I found out my test gameobjects weren't active in the scene. Awake() gets called now after I've activated them.
If you found the right answer please mark this question as closed. Thank you.
Follow this Question
Related Questions
Start() not called upon instantation? 1 Answer
Call method on "Start" of a built-in component? 1 Answer
Awake and start functions execute twice in multiplayer game 2 Answers
Does the access modifier of Start(), Awake(), OnEnable() make a difference to Unity? 3 Answers
How to make Awake and Start get called in order with additive scenes? 1 Answer