Created
December 17, 2014 18:28
-
-
Save tsubaki/13536c2c29860b9754da to your computer and use it in GitHub Desktop.
uGUIのノードをダイナミックに作りたい場合のアレ。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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