NGUI でインターネット上の画像を表示するには
- WWW で画像を読み込み、UITexture で表示する。
サンプル
- 以下のスクリプトを任意のオブジェクトにアタッチして実行する。
using UnityEngine; using System.Collections; [RequireComponent(typeof (UITexture))] public class LoadTextureFromWWWSample : MonoBehaviour { public string url; void Start () { UITexture texture = GetComponent<UITexture> (); StartCoroutine (SetImage (texture, url)); } IEnumerator SetImage (UITexture t, string url) { WWW www = new WWW(url); yield return www; t.mainTexture = www.texture; } }