Skip to main content

Function: addContentSizeFitterComponent()

addContentSizeFitterComponent(world, entity, options?): ContentSizeFitterDefaultedOptions

Defined in: ui/components/content-size-fitter-component.ts:51

Attaches a ContentSizeFitterEcsComponent to entity, resizing its RectTransformEcsComponent's own size every frame (via createUiLayoutGroupEcsSystem, alongside its layout-group handling) to match entity's own measured content size on each configured axis - the same min/preferred size a HorizontalLayoutGroupEcsComponent/ VerticalLayoutGroupEcsComponent/GridLayoutGroupEcsComponent on entity would report to a parent group, or entity's own LayoutElementEcsComponent overrides. With neither, there's no content to measure and this is a no-op - pair it with one of those, most commonly a layout group, to make a panel shrink-wrap its arranged children.

Parameters​

world​

EcsWorld

The ECS world entity belongs to.

entity​

number

The entity to attach the component to. Assumes a point-anchored RectTransformEcsComponent (its x/y are each a literal size, not a stretch margin).

options?​

Partial<ContentSizeFitterEcsComponent> = {}

Options for configuring the fitter.

Returns​

ContentSizeFitterDefaultedOptions

The attached component, for further tuning or runtime changes.