Skip to content

Instantly share code, notes, and snippets.

@tsubaki
Created December 17, 2014 18:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save tsubaki/13536c2c29860b9754da to your computer and use it in GitHub Desktop.
Save tsubaki/13536c2c29860b9754da to your computer and use it in GitHub Desktop.
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