How to play a video in Unity

Source: Internet
Author: User

Unity supports video streaming, that is, you can upload a video and attach it to an animated video object. Basically, the quick time player on your computer can play the video, the supported video formats are as follows:

. Mov,. mpg,. MPEG,. MP4,. Avi,. ASF

The only thing to note is that unity does not play a video automatically. You must add a new row or a number of rows to play the video, the following two Playback modes are provided for the test:

1. the specified worker row is played immediately: function Update () {Renderer. material. maintexture. play ();} 2. custom stream playback: function Update () {If (input. getbuttondown ("jump") {If (Renderer. material. maintexture. isplaying) {Renderer. material. maintexture. pause ();} else {Renderer. material. maintexture. play ();}}}

Usage:

1. Load a video

2. Attach a video to a movie clip (this example uses plane)

3. Add blank JavaScript and upload the program example (Example 1)

4. Add blank JavaScript and upload the program example (Example 2)

5. Attach the notebook to the notebook object

6. Video Playback

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.