0

如果在 atals 中找不到 uisprite spriteName,我想显示另一个 spritename,我该怎么办?请给我一些建议,谢谢!

string aSpriteName = GetIconFromAtlas("item_005");
mTreasure2.transform.FindChild("item/ax/prize1").gameObject.GetComponent<UISprite>().spriteName =aSpriteName;


string GetIconFromAtlas(string spriteName)
{
    string aSpriteName = spriteName;
    if (string.IsNullOrEmpty(aSpriteName)) 
        aSpriteName = "item000";
    return aSpriteName;
}
4

1 回答 1

0
UISpriteData  aData= this.transform.FindChild("Card1/pic/badge").GetComponent<UISprite>().atlas.GetSprite("item_005");
if(aData == null)
    this.transform.FindChild("item/ax/prize1").GetComponent<UISprite>().spriteName = "item000";
于 2015-01-12T05:57:49.497 回答