I have a small container, where I want listed a series of buttons. I try to fill them at Runtime like this:
using UnityEngine;
public class FillWithGearData : MonoBehaviour {
public Transform SelectGearButton;
public Transform GearPanel;
void Awake() {
Transform button = Instantiate(SelectGearButton, new Vector3(0, 0, 0), Quaternion.identity) as Transform;
button.SetParent(GearPanel);
}
}
But the buttons added at Runtime are not adapting to the Layout, even though the ones added before runtime seem to adapt without a problem.
Demo:
What is going on?