Version: Unity 6.2 Alpha (6000.2)
Language : English
Video file compatibility with target platforms
Video encoding compatibility reference

Use unsupported video files in the Editor

To use video files that are compatible with target platforms but incompatible with the Unity Editor, set them up as streaming assets.

  1. Drag your video file into the StreamingAssets folder.
  2. Reference the StreamingAssets URL in the Video Player component. Alternatively, you can use Application.streamingAssetsPath.

Use placeholder video files

If you want to use placeholder versions of your video files that are compatible with your Editor but use a different version for your target platform, you can include both versions in your project and decide which version to use at runtime.

The following example script demonstrates how to use different video URLs for different platforms. For more information, refer to Platform-dependent compilation.

void SetupMovieFile(VideoPlayer vp)
{
   #if UNITY_EDITOR || UNITY_LINUX
   vp.url = pathToMyVp8File;
   #elif UNITY_ANDROID
   vp.url = pathToMyVp9File;
   #elif UNITY_STANDALONE_WIN
   vp.url = pathToMyWmvFile;
   #else
   vp.url = pathToMyMp4File;
   #endif
}

This ensures Unity uses the correct video format at runtime, while allowing placeholder files in the Editor.

Additional resources

Video file compatibility with target platforms
Video encoding compatibility reference
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961