- Home /
Elements of menu with VerticalLayoutGroup don't align properly
Hello,
I have a menu with 10 items on it:
When I click onto an item it is removed from the menu, but the remaining items don't align to the top, but to the center:
These are the settings for my UI element with a Content Size Fitter and a Vertical Layout Group: UI element settings
And this code runs on every menu item:
void Start()
{
rectTrans = FindObjectOfType<MyMenu>().GetComponent<RectTransform>();
}
public void OnPointerClick(PointerEventData eventData)
{
myEvent.Invoke(ItemContent);
Destroy(gameObject);
LayoutRebuilder.MarkLayoutForRebuild(rectTrans);
}
Does anyone has an idea how I can change the settings or the code so the remaining items are aligned to the top of the menu?
Your answer
![](https://koobas.hobune.stream/wayback/20220612192736im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Content size fitter alignment issue 1 Answer
UI Canvas strange child alignment 0 Answers
Problem with Aligning and Scaling of UI Elements 0 Answers
Text component changes the text but doesn't remove the previous version. 0 Answers
How do I place a left or right aligned Text where it would be if it was center aligned? 0 Answers