unity 更换image的Source

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_34696203/article/details/80339561


//声明一张image

public Image Bg;

//声明更换的图片序号

int ImageNum=1;

private string Res_BGPath = "Image/BackGround/"; //背景路径

//更换路径 

Bg.GetComponent<Image>().sprite = Resources.Load(Res_BGPath + ImageNum, typeof(Sprite)) as Sprite;

猜你喜欢

转载自blog.csdn.net/qq_34696203/article/details/80339561
今日推荐