//方法一: Image/pic 在 Assets/Resources/目录下
Image _myImage;
void Start()
{
_myImage.sprite = Resources.Load("Image/pic", typeof(Sprite)) as Sprite;
}
//方法二:mySprite 为外部指定的图片资源
Image _myImage;
Sprite _ISprite; void Start()
{
_myImage.sprite = ISprite
}
//方法三
Image myImage; void Start () { StartCoroutine(GetImage()); }
IEnumerator GetImage()
{
string url = "http://www.5dbb.com/images/logo.gif";
WWW www = new WWW(url);
yield return www;
if (string.IsNullOrEmpty(www.error))
{
Texture2D tex = www.texture;
Sprite temp = Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), new Vector2(0, 0)); myImage.sprite = temp;
}
}