csharp 使用带有Unity 5.6 beta的新VideoPlayer组件播放视频。
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了csharp 使用带有Unity 5.6 beta的新VideoPlayer组件播放视频。相关的知识,希望对你有一定的参考价值。
public class VideoManager : MonoBehaviour
{
[SerializeField]
private RenderTexture _renderTexture = null;
[SerializeField]
private VideoClip _videoClip = null;
private IEnumerator Start()
{
Application.runInBackground = true;
var camera = Camera.main.gameObject;
var videoPlayer = camera.AddComponent<VideoPlayer>();
var audioSource = camera.AddComponent<AudioSource>();
videoPlayer.playOnAwake = false;
audioSource.playOnAwake = false;
videoPlayer.source = VideoSource.VideoClip;
videoPlayer.audioOutputMode = VideoAudioOutputMode.AudioSource;
videoPlayer.renderMode = VideoRenderMode.RenderTexture;
videoPlayer.EnableAudioTrack(0, true);
videoPlayer.SetTargetAudioSource(0, audioSource);
videoPlayer.clip = _videoClip;
videoPlayer.Prepare();
while (!videoPlayer.isPrepared)
yield return null;
videoPlayer.targetTexture = _renderTexture;
videoPlayer.Play();
audioSource.Play();
while (videoPlayer.isPlaying)
yield return null;
ScreenFader.FadeIn(2.5f, () => SceneManager.LoadScene("Menu"));
}
}
以上是关于csharp 使用带有Unity 5.6 beta的新VideoPlayer组件播放视频。的主要内容,如果未能解决你的问题,请参考以下文章
Beta冲刺-代码规范
csharp Beta 19
csharp Beta 19
Unity 5.6 UGUI 按钮被遮挡
[转] Draw Call未被批处理?告诉你在Unity 5.6中如何查找原因 [复制链接]
csharp 在Unity中使用SharpNav.dll