Legacy Documentation: Version 5.2
LanguageEnglish
  • C#
  • JS

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

Removed in version 5.2.1p2
LoadUnityWeb is no longer supported. Please use javascript to reload the web player on a different url instead

WWW.LoadUnityWeb

Suggest a change

Success!

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

Sumbission failed

For some reason your suggested change could not be submitted. Please try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Switch to Manual
public function LoadUnityWeb(): void;
public void LoadUnityWeb();

Description

Loads the new web player data file.

The first level of the loaded .unity3d file will automatically be loaded. All objects, scripts and static variables from the previous .unity3d file will be unloaded. You can move information between the two sessions using PlayerPrefs class.

This function is only supported in the web player.

If the object has not finished downloading the unity3d file will not be loaded. Use isDone or yield to see if the data is available.

	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 gt = GetComponent.<GUITexture>();
	
	var originalPixelRect = gt.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) { gt.pixelInset.xMax = originalPixelRect.xMin + stream.progress * originalPixelRect.width; yield; } // Update it one last time before loading gt.pixelInset.xMax = originalPixelRect.xMax;

stream.LoadUnityWeb(); }