using UnityEngine;
using System.Collections;
using UnityEngine.UI;
/// <summary>
/// 用来测试动态生成下载列表
/// </summary>
public class UILoad : MonoBehaviour
{
int contDown = 4;
//初始位置
int lbx = 200;
//下载列表
public GameObject DownControl0;
// Use this for initialization
void Start()
{
//动态创建下载列表
for (int i = 0; i < contDown; i++)
{
//列表框位置
lbx -= 100;
GameObject temp = Instantiate(Resources.Load("ShowControl")) as GameObject;
temp.transform.parent = DownControl0.transform;
temp.transform.localPosition = new Vector3(0, lbx, 0);
//下载图片显示
Texture2D img = (Texture2D)Resources.Load(i.ToString());
temp.transform.FindChild("texture").GetComponent<Image>().sprite = Sprite.Create(img, new Rect(0, 0, 64, 64), new Vector2(0.5f, 0.5f));
//下载名字
temp.transform.FindChild("LoadName").GetComponent<Text>().text = i.ToString();
//按钮点击事件(用于传递下载连接
temp.transform.FindChild("LoadButton").GetComponent<LoadButton>().str = i.ToString();
}
}
// Update is called once per frame
void Update()
{
}
}