- Home /
LoadLevelAsync movie not playing gui!!
hi i am having problem with making loading screen while the level loads in the background. i am using loadlevelasync function. but the problem is i also have a loading movie, and a loading background image, the images show as planned, however the movie is not playing.
i think the problem is that the level loads before the movie gets any chance to play. so how to solve this, i want to play the movie as loading the level in bg and when the loading is done, it switches to the loaded level.
i am using GUI box to show images and play the movie. here is my code,
var skin:GUISkin;
public var guiDepth : int = 0;
var image: Texture2D;
public var backgroundaudio: AudioClip;
public var PlayVid : MovieTexture;
function Start () {
// Load the level named "MyBigLevel".
var async : AsyncOperation = Application.LoadLevelAsync ("round1");
yield async;
Debug.Log ("Loading complete");
}
function OnGUI()
{
GUI.depth = guiDepth;
GUI.Box(Rect (0,0,Screen.width,Screen.height), image);
PlayVid.loop = true;
PlayVid.Play();
GUI.DrawTexture(Rect (Screen.width - 260,Screen.height - 110,260,110), PlayVid);
}
Why not just not have the movie object destroyed on scene load, then disable scene activation, once the move has completed, activate the scene :)
Answer by MaddyGm3R · Jul 06, 2013 at 07:40 AM
Hi You have put PlayVid.Play();
in the OnGUI function. This will give call to play the video in each onGUI call, but never play it completely as next Play is called before the video can render the next frame. Put PlayVid.Play();
in the start function and watch the magic.
sorry for this late response, was kinda busy. thnx for the tips it worked, though when i play the game in the editor nothing happens, but in the build it worked, guess in the editor the level load completes so soon that the video got no chance to play.