Unity uses RenderTexture to play video screen residual problem

Problem Description:

In the project, the VideoPlayer component provided by Unity is used to play videos. A RenderTexture is created under Assets as a medium. Drag and drop it to the targetTexture attribute of the RawImage and VideoPlayer components to play the video in the UI. However, during use, it was found that switching video playback , every time you start playing a video, the previous frame will first display the content of the last video played.

solution:

  1. Create RenderTexure in real time, avoiding the problem of pre-created images that remain from previously played images.
  2. The VideoPlayer component provides a method,VideoPlayer.targetTexture.Release(), which releases RenderTexture.

Guess you like

Origin blog.csdn.net/weixin_42186644/article/details/119539217