I created a scrollRect for a menu full of buttons.
The number of buttons dynamically changes based on which one is pressed.
There could be as few as 3 buttons or as many at 20.
When there are a greater number of buttons than will fit withing the scrollrect pane mask they can be scrolled by dragging the mouse up and down on the pane.
The buttonpane containing the buttons has a layout element and a grid layout script attached.
The parent content pane has a content size fitter script AND a layout element script and a vertical layout group attached.
The parent of the content pane gameobject is a gameobject that has a scrollrect attached and an image and a mask.
The parent of the scrollrect gameobject is the canvas and has an image attached.
The size of the buttonpane stretches vertically when more buttons are added (when the menu changes).
How to I get the content pane top bound to be aligned with the scrollrect objects top bound whenever the content pane’s number of buttons changes?
I could add a code example but because the whole structure was created and initialized in code and the number of buttons within the grid layout group are enabled/disabled by a lot of other code it would probably be more of a hindrance than a help as it numbers over 500 lines.
The problem is I do not know how many buttons will be in the menu at any one time the contentpane size is driven automatically by the number of buttons currently enabled in the buttonpane child object.
I’m looking for some kind of function that will align the top of one rect transform to the top of another rect tranform in c#.