Horizontal Layout Group does not omit hidden children

Hello! I use Horizontal Layout Group component from New UI to center buttons in scene.

By default there are 2 buttons: Dropbox - Error - Simplify your life

But one may be hidden and another one must be centered: Dropbox - Error - Simplify your life

The problem is that I can’t get this working without making hidden button inactive. I use Canvas Group element to control visibility everywhere in the scene and when I set alpha to 0 button remains in it’s position. Is there any way to enable New UI components take Canvas Group alpha into account when aligning ?

My setup is as follows:

Panel (Horizontal Layout Group; Content Size Fitter, Horizontal Fit=Min Size)

  • Button 1 (Layout Element, Min Width=some unequal width in pixels)
  • Button 2 (same as Button 1)

That setup I’ve taken from best of live training, from Recorded Video Training: Shop UI with Runtime Scroll Lists - Unity Learn

Solved with following hand-written component HorizontalLayoutGroupHelper.cs · GitHub Will be glad to hear your suggestions. I know, that more simple way is just to write own Horizontal Layout Group, but everything in my project is already bound to existing one, so I’ll be really glad to hear any suggestions on solving the issue in another way or improving the script, that I provided