Question by
reviews_unity · Mar 31, 2018 at 05:14 PM ·
uibutton
Help with buttons
Hi, I followed the tutorial linked here: https://www.youtube.com/watch?v=mRC7sz-NAcE&list=PLLH3mUGkfFCWCsGUfwLMnDWdkpQuqW3xa∈dex=2
In the above tutorial when the buttons are spawned the next button continuously follows on from the last. However I am using a vertical scroll rather than a horizontal and instead of appearing below the last one each button just stacks.
Sprite[] missionButtons = Resources.LoadAll<Sprite> ("Missions");
foreach (Sprite missionButton in missionButtons) {
GameObject container = Instantiate (missionButtonPrefab) as GameObject;
container.GetComponent<Image> ().sprite = missionButton;
container.transform.SetParent (MissionContainer.transform, false);
}
Comment
Are you sure the $$anonymous$$issionContainer
gameobject has a HorizontalLayoutGroup
component attached?