言語: 日本語
  • C#
  • JS
  • Boo

スクリプト言語

お好みのスクリプト言語を選択すると、サンプルコードがその言語で表示されます。

WWW.error

public var error: string;

Description

ダウンロード中にエラーが発生した場合のエラーメッセージ (Read Only)

もしエラーがない場合は errornull または空文字(空文字は一部のプラットフォームがstring値としてnullを許可していないため)を返します。 ですので、エラーのチェックを行う場合は両方に対応するためにString.IsNullOrEmptyを使用することをお勧めします。 WWWオブジェクトはデータのダウンロードが完了するまでブロックされています。 データが利用可能かどうかは isDone または yield を使用してください。

	// Get a texture with an invalid url
	var url = "invalid_url";
	function Start () {
	     // Start a download of the given URL
	    var www : WWW = new WWW (url);

	    // Wait for download to complete
	    yield www;

	    // Print the error to the console
	    if (!String.IsNullOrEmpty(www.error))
	    	Debug.Log(www.error);

	    // assign texture
	    renderer.material.mainTexture = www.texture;
	}