读取tag数组按顺序读出sprite
foreach (GameObject obj in GameObject.FindGameObjectsWithTag("CardTop"))
{
//public string[,] strArray = { { "8", "0", "0" }, { "7", "1", "1" }, { "8", "2", "2" }, { "5", "3", "3" }, { "4", "4", "2" } };
for (int i = 0; i < 5;i++ )
{
if (obj.gameObject.name == "A"+(i+1).ToString())
{
foreach (UISprite sp in obj.GetComponentsInChildren<UISprite>())
{
//改变头像
if (sp.gameObject.name == "A"+(i+1).ToString())
{
sp.spriteName = strArray;
}
//改变背景框
if (sp.gameObject.name == "A"+(i+1).ToString()+"BG")
{
sp.spriteName = strArray;
}
//改变名字
if (sp.gameObject.name == "A" + (i + 1).ToString() + "Name")
{
sp.spriteName = strArray;
}
//改变星级
if (sp.spriteName == "icon_sc_star1")
{
if (int.Parse(sp.name.Substring(4, 1)) > int.Parse(strArray))
{
sp.spriteName = "icon_sc_star2";
}
}
}
}
}
} 学习了 学习了 楼主是超人 真心顶 难得一见的好帖 说的非常好 LZ真是人才 楼主是超人 好帖就是要顶 顶顶多好
页:
[1]