Note: This is a Pro/Advanced feature only.
注:這僅是專業(yè)版/高級版的功能。
Desktop
Movie Textures are animated Textures that are created from a video file. By placing a video file in your project's Assets Folder, you can import the video to be used exactly as you would use a regular Texture.
影片紋理(Movie Textures),從視頻文件中創(chuàng)建的動畫紋理(Textures )。通過在項目的資源文件夾中放置一個視頻文件,可以導入要使用的視頻,跟你使用一個普通的紋理(Texture)完全相同。
Video files are imported via Apple QuickTime. Supported file types are what your QuickTime installation can play (usually .mov, .mpg, .mpeg, .mp4, .avi, .asf). On Windows movie importing requires Quicktime to be installed (download here).
視頻文件通過蘋果的QuickTime 導入。支持的文件類型是QuickTime可以播放的文件類型(通常 .mov, .mpg, .mpeg, .mp4, .avi, .asf)。在Windows,影片的導入需要安裝QuickTime(此處下載download here)。
Properties 屬性
The Movie Texture Inspector is very similar to the regular Texture Inspector.
影片紋理檢視面板與普通紋理(Texture )檢視面板非常相似,

Video files are Movie Textures in Unity 視頻文件是在Unity里的影片紋理
-
Aniso Level 各向異性等級
Increases Texture quality when viewing the texture at a steep angle. Good for floor and ground textures
提高在一個陡峭的角度觀看紋理時的紋理質量。適合地板和地面紋理
-
Filtering Mode 過濾模式
Selects how the Texture is filtered when it gets stretched by 3D transformations
選擇當3D變換拉伸時,紋理如何被過濾
Loop 循環(huán)
If enabled, the movie will loop when it finishes playing
如果啟用,影片在完成播放時循環(huán)
Quality 質量
Compression of the Ogg Theora video file. A higher value means higher quality, but larger file size 對Ogg Theora
視頻文件的壓縮。值越高,意味著更高的質量,但文件大小會較大
Details 詳情
When a video file is added to your Project, it will automatically be imported and converted to Ogg Theora format. Once your Movie Texture has been imported, you can attach it to any GameObject or Material, just like a regular Texture.
當一個視頻文件添加到項目中,它會自動導入并轉換為Ogg Theora 格式。一旦你的影片紋理導入后,你可以將它附加到任何游戲對象(GameObject )或材質(Material),就像一個普通的紋理一樣。
Playing the Movie 播放影片
Your Movie Texture will not play automatically when the game begins running. You must use a short script to tell it when to play.
你的影片紋理不會在游戲運行時自動播放。您必須使用一個簡短的腳本來告訴它什么時候播放。
// this line of code will make the Movie Texture begin playing
//這行代碼讓影片紋理開始播放
renderer.material.mainTexture.Play();
Attach the following script to toggle Movie playback when the space bar is pressed:
將下面的腳本來觸發(fā)當空格鍵被按下時,影片播放:
function Update () {
if (Input.GetButtonDown ("Jump")) {
if (renderer.material.mainTexture.isPlaying) {
renderer.material.mainTexture.Pause();
}
else {
renderer.material.mainTexture.Play();
}
}
}
For more information about playing Movie Textures, see the Movie Texture Script Reference page
播放影片紋理的詳細信息,請參閱影片紋理腳本參考頁面
Movie Audio 影片音頻
When a Movie Texture is imported, the audio track accompanying the visuals are imported as well. This audio appears as an AudioClip child of the Movie Texture.
當影片紋理導入后,伴隨著視像和音軌一并導入。該音頻是AudioClip ,作為影片紋理的孩子。

The video's audio track appears as a child of the Movie Texture in the Project View
視頻的音軌作為影片紋理的孩子出現(xiàn)在項目視圖
To play this audio, the Audio Clip must be attached to a GameObject, like any other Audio Clip. Drag the Audio Clip from the Project View onto any GameObject in the Scene or Hierarchy View. Usually, this will be the same GameObject that is showing the Movie. Then use audio.Play() to make the the movie's audio track play along with its video.
播放音頻,音頻剪輯必須貼到一個游戲對象上,像任何其他音頻剪輯。從項目視圖拖動音頻剪輯到場景的任何游戲對象或層級面板視圖。通常,這是播放影片相同的游戲對象。然后使用 audio.Play()使影片的音軌伴隨著其視頻播放。
iOS
Movie Textures are not supported on iOS. Instead a full-screen streaming playback is provided using iPhoneUtils.PlayMovie and iPhoneUtils.PlayMovieURL.
影片紋理在iOS不支持。取而代之的是提供一個全屏幕的流媒體播放,使用iPhoneUtils.PlayMovie和iPhoneUtils.PlayMovieURL。
You can import your video file just like a regular asset or alternatively you can specify a network-based URL to play a movie located on a remote server.
您可以導入您的視頻文件,就像一個普通資源,或者你也可以指定一個基于網(wǎng)絡的網(wǎng)址,播放位于遠程服務器上的一個影片。
You need to keep your videos inside of the StreamingAssets folder located in your Project directory.
你需要保持你的影片在 你的項目目錄下的StreamingAssets文件夾里。
Unity iOS supports any movies that already play correctly on an iPod or iPhone, usually that means files with the extensions .mov, .mp4, .mpv, and .3gp and using one of the following compression standards:
Unity IOS支持任何在iPod或iPhone上可以正確播放的影片,通常是指擴展名為.mov, .mp4, .mpv, .3gp 和使用下列壓縮標準之一:
- H.264 Baseline Profile Level 3.0 video
- MPEG-4 Part 2 video
For more information about supported compression standards consult with iPhone SDK MPMoviePlayerController Class Reference.
欲了解更多有關支持的壓縮標準的信息,查閱MPMoviePlayerController Class Reference。
As soon as you call iPhoneUtils.PlayMovie or iPhoneUtils.PlayMovieURL, the screen will fade from your current content to the designated background color. It might take some time while movie is ready for playing, meanwhile the player will continue displaying the background color and may also display a progress indicator to let the user know the movie is loading. When playback finishes, the screen will fade back to your content.
只要你調用iPhoneUtils.PlayMovie或 iPhoneUtils.PlayMovieURL,屏幕上會逐漸從目前的內容變到指定的背景顏色。而影片播放,這可能需要一些時間,同時播放器將繼續(xù)顯示背景顏色,也可能會顯示一個進度指示器,讓使用者知道影片正在載入。當播放結束時,屏幕上會漸退,回到你的內容。
Video player does not respect switching to mute while playing videos
視頻播放器不支持在播放視頻時切換到靜音
As written above, video files are being played using Apple's embedded player (as of SDK 3.2 and iPhone OS 3.1.2 and earlier), so basically we cannot do anything about this, since it is a bug in Apple's software. So yes, mute switch is not respected here.
正如上面寫的,正在播放的視頻文件,使用蘋果的嵌入式播放器(SDK3.2和iPhone操作系統(tǒng)3.1.2及更早版本),所以基本上我們不能這樣做,因為它是蘋果的軟件中的錯誤。所以,這里不支持靜音開關。
Video player does not respect device orientation
視頻播放不支持設備的方位
Apple video player and iPhone SDK do not provide a way to adjust the orientation of the video. Common approach is to manually create two copies of each movie in landscape and portrait orientations, then to determine the orientation of the device before playback and choose one of two movies.
蘋果視頻播放器和iPhone SDK沒有提供一種方法來調整視頻的方位。常見的方法是在橫向和縱向的方向手動創(chuàng)建每個影片的兩個拷貝,再確定設備的方位,最后就選擇兩個影片中的一個進行播放。
Android
Movie Textures are not supported on Android. Instead a full-screen streaming playback is provided using iPhoneUtils.PlayMovie and iPhoneUtils.PlayMovieURL.
在Android上不支持影片紋理。而是提供一個全屏幕的流媒體播放,使用 iPhoneUtils.PlayMovie和iPhoneUtils.PlayMovieURL.
You can import your video file just like a regular asset or alternatively you can specify a network-based URL to play a movie located on a remote server.
您可以導入您的視頻文件,就像一個普通資源,或者你也可以指定一個基于網(wǎng)絡的網(wǎng)址,播放位于遠程服務器上的一個影片。
You need to keep your videos inside of the StreamingAssets folder located in your Project directory.
你需要保持你的影片在 你的項目目錄下的StreamingAssets文件夾里。
Unity Android supports any movies that already Android platform supports, usually that means files with the extensions .mp4 and .3gp and using one of the following compression standards:
Unity IOS支持任何在iPod或iPhone上可以正確播放的影片,通常是指擴展名為.mov, .mp4, .mpv, .3gp 和使用下列壓縮標準之一:
- H.263
- H.264 AVC
- MPEG-4 SP
However device vendors are keen on expanding this list, so some Android devices are able to play HD videos and other than listed file formats.
然而,設備供應商都熱衷于擴展此列表,因此一些Android設備能夠播放高清視頻和列出文件以外的格式。
For more information about supported compression standards consult with Android SDK Core Media Formats documentation.
有關支持的壓縮標準的更多信息,查閱Android SDK的 Core Media Formats documentation。
As soon as you call iPhoneUtils.PlayMovie or iPhoneUtils.PlayMovieURL, the screen will fade from your current content to the designated background color. It might take some time while movie is ready for playing, meanwhile the player will continue displaying the background color and may also display a progress indicator to let the user know the movie is loading. When playback finishes, the screen will fade back to your content.
只要你調用 iPhoneUtils.PlayMovie或 iPhoneUtils.PlayMovieURL,屏幕上會逐漸從目前的內容變到指定的背景顏色。而影片播放,這可能需要一些時間,同時播放器將繼續(xù)顯示背景顏色,也可能會顯示一個進度指示器,讓使用者知道影片正在載入。當播放結束時,屏幕上會漸退,回到你的內容。