视频播放器 (Video Player) 组件可播放从各种来源导入的内容。
要创建和使用视频剪辑资源,必须先导入视频文件。
将视频文件拖放到 Project 窗口中即可创建一个视频剪辑。
创建视频剪辑的另一种方法是导航到 Assets > Import New Asset… 来导入视频文件。
导入后,可在视频播放器组件中选择新创建的视频剪辑,为此可使用 Select VideoClip 窗口(通过单击 Video Clip 字段右侧的圆圈选择按钮即可访问此窗口),也可将视频剪辑资源拖放到相应的视频播放器组件字段中。
使用 Source 下拉菜单可将视频源设置为 URL__(此属性在默认情况下设置为 Video Clip__)。将 Source 设置为 URL 可直接使用文件系统中的文件(有或没有 file:// 前缀)。
URL 源选项会绕过资源管理,这意味着您必须手动确保 Unity 可以找到源视频。例如,一个 Web URL 需要由 Web 服务器托管源视频,而普通文件必须位于 Unity 可以找到该文件的位置(用脚本表示)。但是,如果内容不在 Unity 的直接控制之下,或者您希望避免在本地存储大型视频文件,则此功能非常有用。
如果将视频播放器组件源设置为 __URL__,也可通过 http:// 和 https:// 从 Web 源读取视频。在这些情况下,Unity 会执行必要的预缓冲和错误管理。
也可从 Asset Bundle 读取视频剪辑。
将这些视频剪辑导入后,即可通过将它们分配给视频播放器组件的 Video Clip 字段来使用它们。
置于 Unity 的 StreamingAssets 文件夹中的文件可通过视频播放器组件的 URL 选项(见上文)进行使用,也可借助特定于平台的路径 (Application.streamingAssetsPath) 进行使用。
2017–06–15 页面已发布
Unity 5.6 中的新功能
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.