在Unity 5.6.0b1发布之后, MovieTexture最终被弃用,现在发布了在桌面和移动设备上播放视频的新API.
如果需要, VideoPlayer和 VideoClip可用于播放视频并检索每个帧的纹理.
我已经设法让视频正常工作但是却没有从Windows 10的编辑器那里得到音频.任何人都知道为什么音频没有播放?
//Raw Image to Show Video Images [Assign from the Editor]
public RawImage image;
//Video To Play [Assign from the Editor]
public VideoClip videoToPlay;
private VideoPlayer videoPlayer;
private VideoSource videoSource;
//Audio
private AudioSource audioSource;
// Use this for initialization
void Start()
{
Application.runInBackground = true;
StartCoroutine(playVideo());
}
IEnumerator playVideo()
{
//Add VideoPlayer to the GameObject
videoPlayer = gameObject.AddComponent<VideoPlayer>();
//Add AudioSource
audioSource = gameObject.AddComponent<AudioSource>();
//Disable Play on Awake for both Video …
Run Code Online (Sandbox Code Playgroud)