How the Check Works
This check examines individual GameObjects within your UI hierarchy. For each GameObject, it checks if it contains a ContentSizeFitter or an AspectRatioFitter. If such components are present, the check proceeds to verify their parent relationships.
The check looks for the following conditions:
- The presence of
ContentSizeFitterorAspectRatioFittercomponents. - Whether the
GameObjecthas anILayoutIgnorercomponent and is set to ignore layout. - Whether the
GameObjectis a child of aRectTransformparent with an enabledILayoutGroupcomponent (such as aLayoutGroup).
If all these conditions are met, it indicates that a ContentSizeFitter or AspectRatioFitter is incorrectly nested within a LayoutGroup. Such nesting can lead to unexpected UI behavior, and the check logs it as an issue.
When to Use This Check
- UI Hierarchy Cleanup: Ensure that your UI hierarchy is correctly structured to avoid unexpected layout issues.
- Prevent Layout Bugs: Detect and rectify incorrectly nested
ContentSizeFittersorAspectRatioFitterswithinLayoutGroupsto prevent layout bugs. - UI Best Practices: Promote adherence to UI best practices by identifying and addressing problematic UI configurations.
How to fix errors like this
You should not have nested layout components in your UI like this. Reexamine the UI you have built and see if you can implement it with fewer components. These components fight against each other to set the size of your objects, resulting in undefined behaviour.
