Let’s say you have an auto layout like this :
Content ( grid layout group )
- AChild 1
- AChild 2
- BChild 1
- CChild 1 ( grid layout group )
- DChild 1
- DChild 2
- BChild 2
- BChild 3
- AChild 3
Now normally if you inspect AChild 1
and DChild 1
it would say “Some values driven by grid layout group”. And these values are saved in the yaml as 0
since they shouldn’t be set. Under the hood each of these children has a rectTransform.drivenByObject
value that’s set to the controlling parent, that is given by the DrivenRectTransformTracker
within the layout groups.
Here’s the problem : If you disable and enable AChild 3
for example, then DChild 1
will lose the drivenByObject
value, and won’t show up as driven. Also all the driven values, like anchorPosition.y
etc will change from 0
to e.g. 153.4
The only fix for this so far, is to not have any gaps in layout groups, like so :
Content ( grid layout group )
- AChild 1
- AChild 2 ( vertical layout group ) <--
- BChild 1 ( vertical layout group ) <--
- CChild 1 ( grid layout group )
- DChild 1
- DChild 2
- BChild 2
- BChild 3
- AChild 3
But that’s very annoying, and sometimes not even possible.