Scaling dynamic created buttons


I’m trying to create a dynamic menu in unity but having a problem where my buttons that i create don’t scale correctly. I’ve put Vertical layout group to my panel but it doesn’t trigger.

Here’s a picture:

The test buttons are the one i create dynamically, i want it to look like the “Previous” button.

Here’s my code where i create the buttons.

using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class menu : MonoBehaviour {

	[SerializeField] GameObject buttonPrefab;
	[SerializeField] Transform menupanel;

	void Start () {

		for (int i = 0; i < 6; i++) {
			GameObject button = (GameObject) Instantiate (buttonPrefab);
			button.GetComponentInChildren<Text>().text = "Test";
			button.transform.localScale = new Vector3 (1.0f, 1.0f, 1.0f);
			button.transform.parent = menupanel;

	// Update is called once per frame
	void Update () {

I too have the same problem. However, I found a workaround. By creating a defaultButton in the parent. At runtime I instantiated from the defaultButton instead of the prefab. Then deactivated/destroyed the defaultButton.