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

スクリプト言語

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

WWW.LoadUnityWeb

public function LoadUnityWeb(): void;

Description

新しいWebプレイヤーのデータファイルをロードします

.unity3d ファイルをロードしたら自動的に最初のレベルがロードされます。 この時に前の .unity3d ファイルにあった全てのオブジェクト、スクリプト、静的変数の値はアンロードされます。 この時は PlayerPrefs クラスを使用して、2つのセッション間で情報を移動させることが出来ます。 この関数はWebプレイヤーのみでサポートされています。 ダウンロードが終了していない場合はunity3dファイルはロードされません。 データが利用可能かどうかは isDone または yield を使用してください。

	function Start () {
		// Start streaming the data file
		var stream =
		  new WWW ("http://www.unity3d.com/webplayers/Lightning/lightning.unity3d");
		// Yield until stream is done
		yield stream;
		// Load it!
		stream.LoadUnityWeb();
	}
	// Streams a .unity3d file and displays the progress in a GUI texture.
	// You need to make sure the GUI texture is set up to have a pixel inset.
	function Start () {
		// Store the original pixel inset
		// and modify it from there.
		var originalPixelRect = guiTexture.pixelInset;

		// Update the progress bar by scaling the gui texture
		// until we reach the end
		var stream =
		  new WWW ("http://www.unity3d.com/webplayers/Lightning/lightning.unity3d");
		while (!stream.isDone) {
			guiTexture.pixelInset.xMax = originalPixelRect.xMin
			      + stream.progress * originalPixelRect.width;

			yield;
		}
		// Update it one last time before loading
		guiTexture.pixelInset.xMax = originalPixelRect.xMax;

		stream.LoadUnityWeb();
	}