- Home /
ChildCount number returns incorrect
I'm making the minesweeper game.
Under gameObjects Row 1, Row2, Row3, Row4, Row5, Row6, Row7, Row 8, Row9, Row10, and Row11 there are 16 children. And this registers for all rows before Row11. I.e, Rows 1 thru 10 all register as having 16 children, but Row11 only registers as having 1, as you can see looking at the code and Console.
This error leads to transform.childCount, when I call it later, to return with the error Transform child out of bounds.
You most likely have another gameObject in your scene called Row11
in your scene.
Use the solution in this question to get the path of your object. It may not be the one you expect.
Answer by eganmike26 · Jun 18, 2020 at 10:27 PM
I solved it basically by redesigning the map. I had all rows nested under an umbrella game object called "Map," and I took them out from under "Map." I also just deleted the map and replaced it.
Your answer
Follow this Question
Related Questions
FindChild/Change color 1 Answer
Detect collision with child object? 2 Answers
Switch for children not working 1 Answer
Foreach loop trying to grab all children in scene 1 Answer
Child-objects are not properly 'transformed' with parent 1 Answer