- Home /
How can play a movie from a button?
Hi!
I'm making a augmented reality project in Unity and I have a game object that displays on the center. (There are other objects with animations on the screen but they are only used as fillers for the scene)
What I want is when I click this object a movie (mp4) will start playing at full screen and when the movie finish it will go back to the scene.
I'm using C# but I'm as you may call a N00B, so if you can guide me step by step to make this possible I would be delighted!
Thanks in advance
Answer by miku00 · Jan 27, 2014 at 06:37 PM
I just wanted to tell you that I solved the problem, I used arrays to maik it work, but at least in my android worls perfectly. Here is the code I used (Is in JS)
pragma strict
/ Use mousedown function in arrays like this
function OnMouseDown() { var pizzaArray = GameObject.FindGameObjectsWithTag ("pizza");
for(var i = 0; i < pizzaArray.length; ++i) { Handheld.PlayFullScreenMovie ("movie.mp4", Color.black, FullScreenMovieControlMode.Full); }
}
Answer by MaT227 · Jan 24, 2014 at 09:28 AM
This will depend on the platform you target and your GUI system.
Here are some really useful documentation if you want to play a video.
Here is the Movie Texture system and the MovieTexture class. It doesn't work on all platforms.
On mobile, you'll need to use the Handheld class.
You can also look at the Unity Assetstore and see if you find something interesting.
To resume.
Choose you target platform.
Choose your GUI system (built-in, NGUI, etc...).
Look at the associated documentation they have great and easy examples.
The plataform is for android and IOS so the movie texture is out of the question, I want to call the video (strea$$anonymous$$g) and play it. So far I used the
Handheld.PlayFullScreen$$anonymous$$ovie ("movie.mp4", Color.black, FullScreen$$anonymous$$ovieControl$$anonymous$$ode.Full);
attached to a game object but it does not seem to work...
Did you put the video in the Strea$$anonymous$$gAssets folder with the good path ?
yes... and is very rare but I can't find a way to make it work... used also the ray method to identify the object as a click object... also tried on$$anonymous$$ouseUp... etc
I suggest you to try with a simple gui button with a Debug.Log() inside to see if it's your selection system of the video system that fails. If it goes in the if`(GUI.Button())`...Then try with a simple Handheld.PlayFullScreen$$anonymous$$ovie ("movie.mp4");
Did you solved your issue ? It would be cool to post an answer or to validate and answer.
Your answer
Follow this Question
Related Questions
Editor Objects ignoring collisions until clicked. 0 Answers
Player click event got triggered when non player is clicked 1 Answer
How i do a clicker with moving objects? 1 Answer
Popup Textures for game objects 1 Answer
Clicking problem on 2D 4 Answers