RenderHeads / UnityPlugin-AVProVideo

AVPro Video is a multi-platform Unity plugin for advanced video playback
https://www.renderheads.com/products/avpro-video/
232 stars 28 forks source link

Runtime created material on UI Image doesn't show video #1435

Closed RuudvanReenen closed 1 year ago

RuudvanReenen commented 1 year ago

Please DO NOT LINK / ATTACH YOUR PROJECT FILES HERE

Describe the issue At runtime I'm creating and assigning a new material with the 'AVProVideo-Unlit' shader and assign the material to an UI Image and to an ApplyToMaterial component connected to a MediaPlayer. This is done to make sure the MediaPlayer uses it's own unique material. Other UI Images can be used with other MediaPlayers to display different videos at the same time. After assigning the material to the ApplyToMaterial component, I'm setting the TexturePropertyName to "_MainTex".

In the Editor, in play mode: When the video plays, it shows the video in the Inspector for both the MediaPlayer component and the Video Material component of the UI Image, but in the Play area the UI Image itself stays black (a black texture is set as DefaultTexture in ApplyToMaterial). When I change one element of the Image component in the Inspector (for example check/uncheck the Raycast Target checkbox, or the Maskable checkbox) the video shows up correctly in the Play area. Any idea how I can make the Image show the video in the Play area without touching anything in the Inspector?

Your Setup (please complete the following information):

RuudvanReenen commented 1 year ago

Here's a minimal test project for Unity 2021.3.12f1: [redacted, please don't link to projects here]

RuudvanReenen commented 1 year ago

The same issue happens when using a RawImage instead of an Image

RuudvanReenen commented 1 year ago

Found out I can use a DisplayuGUI component that directly connects to the MediaPlayer, no need to create separate materials then.