Hi,
I’m loading a video from a script, into a RenderTexture of a static size, so the video is rendered centred / contained within the RenderTexture.
I have two related problems with this:
#1: Before the video starts playing, the RenderTexture is shown black, which appears like a black rectangle in the game
#2: If the video aspect ratio does not match the RenderTexture’s aspect ratio, there will be black bars on top and bottom of the rectangle.
This is the code I’m using:
var rendTex = new CustomRenderTexture(rendTexWidth, rendTexHeight, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Default);
rendTex.initializationMode = CustomRenderTextureUpdateMode.OnDemand;
rendTex.initializationSource = CustomRenderTextureInitializationSource.TextureAndColor;
rendTex.initializationTexture = VideoMaterials.VideoDefaultFrame;
rendTex.initializationColor = new Color(1, 0, 0, 0);
rendTex.autoGenerateMips = false;
rendTex.useMipMap = false;
_videoPlayer = photoGo.AddComponent<VideoPlayer>();
_videoPlayer.renderMode = VideoRenderMode.RenderTexture;
_videoPlayer.targetTexture = rendTex;
The CustomRenderTexture initialisation colour stuff doesn’t work at all - the rectangle is still black, even though it should be a colorized texture.
Ideally, I’d want either a texture shown there before the video starts playing, with an alpha channel so if the middle of the RenderTexture is used up by the video, there are no black bars on the top and bottom of the rectangle, or just the entire RenderTexture to contain 100% transparent pixels.
Any pointers?