Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
uGUIのノードをダイナミックに作りたい場合のアレ。
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class ScrollController : MonoBehaviour {
[SerializeField]
RectTransform prefab = null;
void Start ()
{
for(int i=0; i<15; i++)
{
var item = GameObject.Instantiate(prefab) as RectTransform;
item.SetParent(transform, false);
var text = item.GetComponentInChildren<Text>();
text.text = "item:" + i.ToString();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment