Unity-Technologies / Unity-Technologies/uGUI

BUG: Auto Layout: Horizontal layout cannot preserve child aspect but AspectRatioFitter is not layout aware

Open
#13 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
1.6k
Forks
323
PR merge metrics
No merged PRs in 30d

Description

Suppose you want to a achieve an effect like the dock on MacOS where scaling the tray Rect causes the child icons to scale up while preserving their aspect and laying out horizontally center-middle.

This effect cannot be achieved because the layout can only upscale the width and height it cannot perform an aspect preserving scale.

Attaching an AspectRatioFitter to the child does achieve the desired effect, but on Start() the horizontal layout will shove all of the children to overlap each-other as I guess it believes their width is zero.
Then the layout group forces the scale height of the child to fill itself, and the aspect ratio fitter scales the object to the correct aspect because height controls width, but following this, the horizontal auto-layout does not execute again, so the newly sized rects do not correctly move into place.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the described Horizontal Layout Group and child AspectRatioFitter setup, including the overlapping children on Start(). Trace the layout pass after the fitter changes the child dimensions; done means horizontally arranged children preserve their aspect ratio, fill the intended height, and no longer overlap.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
game-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.