Hi,
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:
![alt text][1]
[1]: /storage/temp/80260-screenshot-2016-10-16-130710.png
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 = "Test";
button.transform.localScale = new Vector3 (1.0f, 1.0f, 1.0f);
button.transform.parent = menupanel;
}
}
// Update is called once per frame
void Update () {
}
}
↧