Video Player在SceneManager.LoadScene上转换后出现的帧

时间:2017-08-11 18:30:48

标签: c# unity3d

我使用SceneManager.LoadScene加载使用Unity新视频播放器组件的场景。鉴于360电影在前一场景被破坏时发生的瞬间失速 - 我决定使用RawImage动画作为从完全透明到黑色的过渡。这掩盖了问题,但是在下一个视频加载之前,前一个视频中的帧出现在转换之后和LoadScene之前,后者立即继续进行。任何解决这个问题的方法将不胜感激!与此相关的代码如下:

sphere.GetComponent<VideoPlayer>().Pause();
rawImage.GetComponent<Animation> ().Play ("FadeOut");
yield return new WaitForSeconds (0.5f); //matches length of time of animation
SceneManager.LoadScene (scene_Name);

enter image description here

我被建议在脚本中执行此操作,但使用下面的代码我遇到了完全相同的问题。

rawImage.GetComponent<RawImage> ().enabled = true;
sphere.GetComponent<VideoPlayer>().Pause();
for (int i = 0; i < 101; i++) {
    float transitionCounter = i / 100f;
    yield return new WaitForSeconds (0.0001f);
    Color temp = rawImage.GetComponent<RawImage> ().color;
    temp.a = transitionCounter;
    rawImage.GetComponent<RawImage> ().color = temp;
}
SceneManager.LoadScene (scene_Name);

谢谢!

1 个答案:

答案 0 :(得分:0)

终于解决了这个问题。最简单的解决方案是在从黑色开始的下一个场景中创建定时淡入。这样,被遗留的框架就不可见了。