【发布时间】:2016-02-18 03:02:10
【问题描述】:
我需要代码和指导。我有一个按钮和一个人体模型。我创建了人和两个纹理,但我的代码没有改变人的纹理。
public Sprite myImage;
public Button kirmizi;
void Start()
{
myImage = Resources.Load<Sprite>("SportyGrilSkin1.png"); // Make sure not to include the file extension
//Make sure it is added in the Inspector. Or reference it using GameObject.Find.
kirmizi.image.sprite = myImage; // That is right, no need to GetComponent.
}
// Update is called once per frame
void Update () {
}
【问题讨论】:
-
正如答案指出的那样,您将精灵放在按钮上而不是任何模型上,但也可能值得指出的是您的文件名中有错字。如果实际文件名有相同的拼写错误,这不会影响功能,但如果它不同,则值得指出。