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 )。通過在項(xiàng)目的資源文件夾中放置一個(gè)視頻文件,可以導(dǎo)入要使用的視頻,跟你使用一個(gè)普通的紋理(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 導(dǎo)入。支持的文件類型是QuickTime可以播放的文件類型(通常 .mov, .mpg, .mpeg, .mp4, .avi, .asf)。在Windows,影片的導(dǎo)入需要安裝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
提高在一個(gè)陡峭的角度觀看紋理時(shí)的紋理質(zhì)量。適合地板和地面紋理
-
Filtering Mode 過濾模式
Selects how the Texture is filtered when it gets stretched by 3D transformations
選擇當(dāng)3D變換拉伸時(shí),紋理如何被過濾
Loop 循環(huán)
If enabled, the movie will loop when it finishes playing
如果啟用,影片在完成播放時(shí)循環(huán)
Quality 質(zhì)量
Compression of the Ogg Theora video file. A higher value means higher quality, but larger file size 對Ogg Theora
視頻文件的壓縮。值越高,意味著更高的質(zhì)量,但文件大小會較大
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.
當(dāng)一個(gè)視頻文件添加到項(xiàng)目中,它會自動導(dǎo)入并轉(zhuǎn)換為Ogg Theora 格式。一旦你的影片紋理導(dǎo)入后,你可以將它附加到任何游戲?qū)ο螅℅ameObject )或材質(zhì)(Material),就像一個(gè)普通的紋理一樣。
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.
你的影片紋理不會在游戲運(yùn)行時(shí)自動播放。您必須使用一個(gè)簡短的腳本來告訴它什么時(shí)候播放。
// 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ā)當(dāng)空格鍵被按下時(shí),影片播放:
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
播放影片紋理的詳細(xì)信息,請參閱影片紋理腳本參考頁面
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.
當(dāng)影片紋理導(dǎo)入后,伴隨著視像和音軌一并導(dǎo)入。該音頻是AudioClip ,作為影片紋理的孩子。

The video's audio track appears as a child of the Movie Texture in the Project View
視頻的音軌作為影片紋理的孩子出現(xiàn)在項(xiàng)目視圖
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.
播放音頻,音頻剪輯必須貼到一個(gè)游戲?qū)ο笊希袢魏纹渌纛l剪輯。從項(xiàng)目視圖拖動音頻剪輯到場景的任何游戲?qū)ο蠡驅(qū)蛹壝姘逡晥D。通常,這是播放影片相同的游戲?qū)ο蟆H缓笫褂?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不支持。取而代之的是提供一個(gè)全屏幕的流媒體播放,使用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.
您可以導(dǎo)入您的視頻文件,就像一個(gè)普通資源,或者你也可以指定一個(gè)基于網(wǎng)絡(luò)的網(wǎng)址,播放位于遠(yuǎn)程服務(wù)器上的一個(gè)影片。
You need to keep your videos inside of the StreamingAssets folder located in your Project directory.
你需要保持你的影片在 你的項(xiàng)目目錄下的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上可以正確播放的影片,通常是指擴(kuò)展名為.mov, .mp4, .mpv, .3gp 和使用下列壓縮標(biāo)準(zhǔn)之一:
- 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.
欲了解更多有關(guān)支持的壓縮標(biāo)準(zhǔn)的信息,查閱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.
只要你調(diào)用iPhoneUtils.PlayMovie或 iPhoneUtils.PlayMovieURL,屏幕上會逐漸從目前的內(nèi)容變到指定的背景顏色。而影片播放,這可能需要一些時(shí)間,同時(shí)播放器將繼續(xù)顯示背景顏色,也可能會顯示一個(gè)進(jìn)度指示器,讓使用者知道影片正在載入。當(dāng)播放結(jié)束時(shí),屏幕上會漸退,回到你的內(nèi)容。
Video player does not respect switching to mute while playing videos
視頻播放器不支持在播放視頻時(shí)切換到靜音
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及更早版本),所以基本上我們不能這樣做,因?yàn)樗翘O果的軟件中的錯(cuò)誤。所以,這里不支持靜音開關(guān)。
Video player does not respect device orientation
視頻播放不支持設(shè)備的方位
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沒有提供一種方法來調(diào)整視頻的方位。常見的方法是在橫向和縱向的方向手動創(chuàng)建每個(gè)影片的兩個(gè)拷貝,再確定設(shè)備的方位,最后就選擇兩個(gè)影片中的一個(gè)進(jìn)行播放。
Android
Movie Textures are not supported on Android. Instead a full-screen streaming playback is provided using iPhoneUtils.PlayMovie and iPhoneUtils.PlayMovieURL.
在Android上不支持影片紋理。而是提供一個(gè)全屏幕的流媒體播放,使用 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.
您可以導(dǎo)入您的視頻文件,就像一個(gè)普通資源,或者你也可以指定一個(gè)基于網(wǎng)絡(luò)的網(wǎng)址,播放位于遠(yuǎn)程服務(wù)器上的一個(gè)影片。
You need to keep your videos inside of the StreamingAssets folder located in your Project directory.
你需要保持你的影片在 你的項(xiàng)目目錄下的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上可以正確播放的影片,通常是指擴(kuò)展名為.mov, .mp4, .mpv, .3gp 和使用下列壓縮標(biāo)準(zhǔn)之一:
- 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.
然而,設(shè)備供應(yīng)商都熱衷于擴(kuò)展此列表,因此一些Android設(shè)備能夠播放高清視頻和列出文件以外的格式。
For more information about supported compression standards consult with Android SDK Core Media Formats documentation.
有關(guān)支持的壓縮標(biāo)準(zhǔn)的更多信息,查閱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.
只要你調(diào)用 iPhoneUtils.PlayMovie或 iPhoneUtils.PlayMovieURL,屏幕上會逐漸從目前的內(nèi)容變到指定的背景顏色。而影片播放,這可能需要一些時(shí)間,同時(shí)播放器將繼續(xù)顯示背景顏色,也可能會顯示一個(gè)進(jìn)度指示器,讓使用者知道影片正在載入。當(dāng)播放結(jié)束時(shí),屏幕上會漸退,回到你的內(nèi)容。