お好みのスクリプト言語を選択すると、サンプルコードがその言語で表示されます。
Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.
CloseダウンロードしたデータからTexture2Dを生成し返します (Read Only)
対応している形式はJPG、PNG になります。データが有効ではない場合、
テクスチャは?マークの小さな画像が生成されます。
また、これは画像のサイズがそれぞれ2のべき乗であることをお勧めします。
任意のサイズでも動作するのですが、若干ロードに時間がかかり、
メモリも消費します。textureプロパティを呼び出す毎に新規のTexture2Dが割り当てられます。
継続的にテクスチャをダウンロードするには LoadImageIntoTexture を使用するか、
前のテクスチャを Destroy で破棄しなければいけません。
PNGファイルで、PNGファイルにガンマ情報が含まれている場合、ガンマ補正はテクスチャに適用されます。
補正のためのディスプレイガンマは2.0と仮定されます。
ガンマ情報が含まれていない場合、色の補正は行われません。
JPGファイルは RGB24 フォーマットでロードされ、PNGファイルは
ARGB32 フォーマットでロードされます。ダウンロードした画像をDXT圧縮したい場合は、
代わりに LoadImageIntoTexture を使用してください。
データのダウンロードが完了していない場合にはダミーの画像が返されます。
データが利用可能かどうかは isDone または yield
を使用してください。
// Get the latest webcam shot from outside "Friday's" in Times Square var url = "http://images.earthcam.com/ec_metros/ourcams/fridays.jpg"; function Start () { // Start a download of the given URL var www : WWW = new WWW (url); // Wait for download to complete yield www; // assign texture renderer.material.mainTexture = www.texture; }
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; } }
import UnityEngine import System.Collections public class ExampleClass(MonoBehaviour): public url as string = 'http://images.earthcam.com/ec_metros/ourcams/fridays.jpg' def Start() as IEnumerator: www as WWW = WWW(url) yield www renderer.material.mainTexture = www.texture