上海杨浦大连路地铁站单机版电子沙盘
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

46 lines
1.5 KiB

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class DrawEquipItem : MonoBehaviour {
private Transform content;
private GameObject equipItem;
private const string imagepath="UI/EquipImage/";
// Use this for initialization
void Start () {
equipItem = Resources.Load("UI/EquipUI/EquipItemToggle") as GameObject;
content = transform.Find("Viewport/Content");
for (int i = 0; i < EquipSelect.GetInstance. Equips.Count; i++)
{
if (EquipSelect.GetInstance. Equips[i].Type ==name&& EquipSelect.GetInstance.Equips[i].Group.Contains(transform.parent.name))
{
Draw(EquipSelect.GetInstance.Equips[i].PicName);
}
}
SetToggleGroup();
}
private void Draw(string equipname)
{
GameObject item = Instantiate(equipItem,content);
item.transform.Find("Image").GetComponent<Image>().sprite = Resources.Load(imagepath+equipname, typeof(Sprite)) as Sprite;
item.transform.Find("Label").GetComponent<Text>().text = equipname;
item.name = equipname;
}
private void SetToggleGroup()
{
for (int i = 0; i < content.childCount; i++)
{
Equip eq = EquipSelect.GetInstance.GetInitInfoByName(content.GetChild(i).name);
if (eq.IsSelectMore)
{
content.GetChild(i).GetComponent<Toggle>().group = content.GetComponent<ToggleGroup>();
}
}
}
}