Quantcast
Channel: Questions in topic: "dynamically"
Viewing all articles
Browse latest Browse all 152

Scaling dynamic created buttons

$
0
0
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 () { } }

Viewing all articles
Browse latest Browse all 152

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>