How the Check Works
This check examines individual GameObject
s 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
ContentSizeFitter
orAspectRatioFitter
components. - Whether the
GameObject
has anILayoutIgnorer
component and is set to ignore layout. - Whether the
GameObject
is a child of aRectTransform
parent with an enabledILayoutGroup
component (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
ContentSizeFitters
orAspectRatioFitters
withinLayoutGroups
to 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.