using UnityEngine;  
using System.Collections;  
using UnityEngine.UI;  
    
public class Test : MonoBehaviour {  
    
    [SerializeField]  
    Image myImage;  
    
    // Use this for initialization  
    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;  
        }  
    }  
} 

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-24
  • 2022-12-23
  • 2021-04-05
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-15
  • 2021-06-21
  • 2022-01-12
  • 2021-07-08
相关资源
相似解决方案