DapremeeA
DapremeeA

Reputation: 1

Unit test gameobjects on scene

I'm having troubles trying to do unit tests. I have a method adding gameobjects on scene, each gameobject has a different position and rotation and a parent. I want to run tests to check my objects are added to their parent with the same position and rotation.

I tried in playmode tests but I keep getting NullReferenceException when doing GameObject.Find() I did the same test in edit mode, but it doesn't work because all objects are not initialized.

How can I test gameobjects on scene when awake and start monobehaviours method have been called ?

I hope someone can help me

Upvotes: 0

Views: 1139

Answers (1)

BlackDereker
BlackDereker

Reputation: 66

You can try to reference each object spawned and store them in an array.

After that, you can iterate over the array to test it.

Gameobject.Find(...) is costly and can become a problem if want to rename your object in your scene without breaking the script.

Upvotes: 0

Related Questions