- Home /
How do you play video in unity?
Hello
I have Unity pro and you can inport video files for the game but I have no idea how to make the video play when the game is activated I thought it would be just a simple drag and drop but nothing is that easy so how would i make a video play?
Thanks
please make sure to check mark answers when they have been answered.
Answer by rawatenator · Apr 14, 2012 at 06:25 PM
Is this what you are looking for? (from http://unity3d.com/support/documentation/Manual/Video%20Files.html)
function Update () {
if (Input.GetButtonDown ("Jump")) {
if (renderer.material.mainTexture.isPlaying) {
renderer.material.mainTexture.Pause();
}
else {
renderer.material.mainTexture.Play();
}
}
}
Answer by Aqibsadiq · Dec 03, 2015 at 09:41 AM
i think the best answer for that is Handheld.PlayFullScreenMovie(VideoPath);
Make a Folder Named StreamingAssets inside of Assets Folder and Place your video in that folder. eg. That Video's name is Test.mp4
now all you have to do is to Write this Code
Handheld.PlayFullScreenMovie("Test.mp4");
Answer by luzanb · Mar 15, 2017 at 09:07 PM
After Unity 5.6 MovieTexture will no longer be used. With new Unity 5.6, VideoPlayer and VideoClip API should be used to play videos. Here's a very nice tutorial for that.
http://justcode.me/unity2d/how-to-play-videos-on-unity-using-new-videoplayer/
Answer by psykojello2 · Nov 13, 2015 at 12:11 PM
I know this was asked in 2012, but for anyone searching in 2015, you can use : Handheld.PlayFullScreenMovie() to play a video file on mobile.