Search Unity

Bug RenderTexture loses video feed in play mode

Discussion in 'Audio & Video' started by alevjen, Apr 14, 2023.

  1. alevjen

    alevjen

    Joined:
    Sep 11, 2020
    Posts:
    11
    Can anyone help me with this issue?

    I have a quad with a material assigned which has a render texture assigned to the "_MainTex" slot.


    RenderTexture = new RenderTexture(Texture.width, Texture.height, 1);
    RenderTexture.Create();
    PlaceholderVideoMaterial = Resources.Load<Material>(_placeholderMaterialLocation);
    PlaceholderVideoMaterial.SetTexture("_MainTex", RenderTexture);

    VideoPlayer = GetComponent<VideoPlayer>();
    VideoPlayer.clip = Resources.Load<VideoClip>(_placeholderClipLocation);
    VideoPlayer.prepareCompleted += VideoPlayerPrepareCompleted;
    VideoPlayer.Prepare();

    private void VideoPlayerPrepareCompleted(VideoPlayer source)
    {
    source.prepareCompleted -= VideoPlayerPrepareCompleted;
    source.Play();
    }


    upload_2023-4-14_10-35-33.png

    When I load my video player in my script it shows in the editor on the quad, but as soon as I hit play, the render texture loses the video.

    upload_2023-4-14_11-32-15.png


    public void Start()
    {
    if (VideoPlayer)
    {
    VideoPlayer.prepareCompleted += VideoPlayerPrepareCompleted;
    VideoPlayer.Prepare();
    }
    }


    Then when i press stop, it is still a blank render texture.

    upload_2023-4-14_10-35-19.png

    However, looking at the render texture in the inspector it seems to still have the video playing

    upload_2023-4-14_10-40-55.png
    upload_2023-4-14_11-29-18.png