So I’ve got 2 children for an object, that when I try to access through any transform-child-get method, I will get an unexpected response.
So here’s an object order that works in the hierarchy window:
Objects of interest in even positions
And here’s an order that does not work:
Objects of interest in odd positions
The inactive objects are empty objects containing a transform component only. The active child are objects containing a transform and a spriterenderer component to create a 2D backdrop.
The parent contains multiple components to create a 3D animation.
For some reason trying to access the children of this object dynamically, through any transform-child-get command I can find only looks through the child in the even positions in the hierarchy window.
For example, in image 1:
//Will see and return both active children .GetComponentsInChildren<Transform>(); .transform.GetChild(i); .transform.childCount;
In image 2:
//Will see and return nothing .GetComponentsInChildren<Transform>(); .transform.GetChild(i); //Will see and return both inactive children .transform.childCount;
I cannot for the life of me work it out.
Unity Editor 2021.3.9f1, also tried in 10f1.
I have not tried remaking the project from scratch as it’s quite large already and was hoping to find a solution first.
Any other ways to access children from a gameobject dynamically I can use to access their components?
This question is not yet answered, be the first one who answer using the comment. Later the confirmed answer will be published as the solution.