- Home /
Movie Play Full Screen
In my game I am building it so that onece you complete the level it loads another scene that would be the cutscene and after the move completes it loads my next game playe. Where my problem comes in is making it so that my movie plays full screen. Currently my movie is on a plane with the fallowing code on it.
function Start(){
renderer.material.mainTexture.Play();
yield WaitForSeconds(8);
Application.LoadLevel("Boat");
}
You can try using a GUITexture for the movie file and creating a script that resizes texture based on window size
Can both of you paste the code formatted, so that it can be viewed by other users? I'm trying to follow what you suggest, and its not very pleasant that way:)
Answer by CC Inc · Apr 21, 2012 at 09:40 PM
GUI.DrawTexture(Rect(0,0,Screen.width,Screen.height),MovieTexture,ScaleMode.StretchToFill);
then play the movie texture using MovieTexture.Play();
you may also want to set Screen.fullScreen = true;
and hide the cursor using Screen.showCursor = false;
and when Escape is pressed and released you may want to re-show the cursor and minimize the screen to its original location:
function Update() {
if (Input.GetKeyUp(KeyCode.Escape)) {
Screen.showCursor = true;
Screen.fullScreen = false;
// in webplayer the fullscreen mode is automatically escaped when "Escape" is pressed
}
}
It says no appropriate version of 'unityEngine.GUI.DrawTexture' for the argument list '(UnityEngine.Rect, System.Type, UnityEngine.Scale$$anonymous$$ode)' was found
Answer by cmos · Jun 08, 2012 at 08:19 PM
Got most of this code from somewhere else on this site. Added the part to keep the video ratio (ex. 16:9)
var movieTexture = new MovieTexture(); var goToScene : String; function Start(){ //MovieTexture.Play(); movieTexture.Play(); while (!movieTexture.isReadyToPlay) yield; // Initialize gui texture to be 1:1 resolution centered on screen guiTexture.texture = movieTexture; transform.localScale = Vector3 (0,0,0); transform.position = Vector3 (0.5,0.5,0); print("H"+movieTexture.height); print("W"+movieTexture.width); print(1.0*movieTexture.height/movieTexture.width);pragma strict
/MovieTexture VideoTexture;
//Keep Ratio (ex. 16:9) guiTexture.pixelInset.xMin = -Screen.width / 2; guiTexture.pixelInset.xMax = Screen.width / 2; guiTexture.pixelInset.yMin = -(1.0*movieTexture.height/movieTexture.width*Screen.width) / 2.0; guiTexture.pixelInset.yMax = (1.0*movieTexture.height/movieTexture.width*Screen.width) / 2.0; //Stretch video to full screen / guiTexture.pixelInset.xMin = -movieTexture.width / 2; guiTexture.pixelInset.xMax = movieTexture.width / 2; guiTexture.pixelInset.yMin = -movieTexture.height / 2; guiTexture.pixelInset.yMax = movieTexture.height / 2;/ // Assign clip to audio source // Sync playback with audio audio.clip = movieTexture.audioClip; // Play both movie & sound movieTexture.Play(); audio.Play(); } // Make sure we have gui texture and audio source @script RequireComponent (GUITexture) @script RequireComponent (AudioSource)
Your answer