**Hello.
I'm a Maya animator. i'm new with unity. i built a simple game and a short movie in 3d as a presentation for my game. format of the video is avi and i would like to make this video start play befor the menu and the game and when it finish the menu appear.
a second question please. a make a level in my game when it appear a question to the player and he has 3 answer posed in a three box. the player must stand on the right box for open the door. so how can i script my box to open the door when he will be pressed by the player.
Create a additional scene. This will be your movie scene.
Add to it a empty GameObject.
Create a new Javascript script, assign it to your gameObject.
Try the following code:
// assign your movie file in the editor
var movieTexture : MovieTexture;
function OnGUI()
{
// center your movie on the screen
var leftOffset = (Screen.width - movieTexture.width)/2;
var topOffset = (Screen.height - movieTexture.height)/2;
GUI.DrawTexture(Rect(leftOffset,topOffset,movieTexture.width, movieTexture.height, movieTexture);
}
function Start()
{
// we add the audio from the video as clip to the AudioSource
audio.clip = movieTexture.audioClip;
// start the movie (sound is synchronized automatically)
movieTexture.Play();
// we want to start the next scene right after the clip finished playing
// there must be a way to get the length of the movie directly from it,
// but I don't know it right now - this should work as well
Invoke("LoadNewLevel", audio.clip.length);
}
function LoadNewLevel()
{
// You will have to change this name to the name of your next scene
Application.LoadLevel("firstLevel");
}
// your audio needs an AudioSource component
@script RequireComponent(AudioSource)
I don't know whether it's the best way, but I think it is a possible way to do this.
I haven't tried the code, but I hope it works :).
The Script gave an error and also you did not explain how to add the Video ,
Shall i create a gui texture and add it to the empty object we created and add the video to it.
Please advice on the script as i tried it and it gave me errors