Unity API WWW下載

屬性 

texture

返回從下載數據生成的Texture2D(只讀)。

text

以字符串(只讀)的形式返回獲取的web頁面的內容。

progress

下載進度(只讀)

bytes

以字節數組(只讀)的形式返回獲取的web頁面的內容。

isDone

是否已經下載完成

 

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class WWWTest : MonoBehaviour {

    public string url = "https://dss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=277944827,2176850960&fm=26&gp=0.jpg";
    IEnumerator Start()
    {
        WWW www = new WWW(url);
        yield return www;//暫停等待下載完成
        Renderer renderer = GetComponent<Renderer>();//獲取Renderer組件
        renderer.material.mainTexture = www.texture;//將圖片設置給模型做爲貼圖
    }
}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章