Load Textrue with WWW
Unity3D/Script / 2014. 12. 2. 00:59
[WWW.texture] : http://docs.unity3d.com/ScriptReference/WWW-texture.html
using UnityEngine; using System.Collections; public class ExampleClass : MonoBehaviour { public string url = "http://images.earthcam.com/ec_metros/ourcams/fridays.jpg"; IEnumerator Start() { WWW www = new WWW(url); yield return www; renderer.material.mainTexture = www.texture; } }
[WWW.LoadImageIntoTexture] : http://docs.unity3d.com/ScriptReference/WWW.LoadImageIntoTexture.html
// Continuously get the latest webcam shot from outside "Friday's" in Times Square // and DXT compress them at runtime var url = "http://images.earthcam.com/ec_metros/ourcams/fridays.jpg"; function Start () { // Create a texture in DXT1 format renderer.material.mainTexture = new Texture2D(4, 4, TextureFormat.DXT1, false); while(true) { // Start a download of the given URL var www = new WWW(url); // wait until the download is done yield www; // assign the downloaded image to the main texture of the object www.LoadImageIntoTexture(renderer.material.mainTexture); } }
반응형
'Unity3D > Script' 카테고리의 다른 글
timeScale Lerp for Unity 3D: Custom Time Manager (0) | 2015.03.09 |
---|---|
외부 이미지 다운로드 후 png 파일 저장 하는 방법 (0) | 2014.12.02 |
OnGUI() 상에서 마우스 더블 클릭 구현 (0) | 2014.11.20 |
LightMap 동적 로딩. (0) | 2014.10.01 |
좀 더 복잡한 데이터 저장하기 (6) | 2014.09.25 |