Menampilkan gambar dari URL
How Load Image from URL
Masukkan kode sbb pada MainCamera (drag script ke MainCamera):
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class loadImage : MonoBehaviour {
string url="http://lp2maray.com/2017/assets/images/desktop.png";
Texture2D img;
// Use this for initialization
void Start () {
StartCoroutine (LoadImg ());
}
void Update () {}
IEnumerator LoadImg(){
yield return 0;
WWW imglink=new WWW(url);
yield return imglink;
img=imglink.texture;
}
void OnGUI(){
GUILayout.Label (img);
}
}
Masukkan kode sbb pada MainCamera (drag script ke MainCamera):
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class loadImage : MonoBehaviour {
string url="http://lp2maray.com/2017/assets/images/desktop.png";
Texture2D img;
// Use this for initialization
void Start () {
StartCoroutine (LoadImg ());
}
void Update () {}
IEnumerator LoadImg(){
yield return 0;
WWW imglink=new WWW(url);
yield return imglink;
img=imglink.texture;
}
void OnGUI(){
GUILayout.Label (img);
}
}
Jadi saat di jalankan...gambar langsung nampil pada canvas.....
Menampilkan gambar dari URL
Reviewed by ADIARRAY
on
15.56
Rating:
Tidak ada komentar: