I want to change the rendermode of my VideoPlayer during runtime but it doesn’t work.
Is it even possible to do that or have I missed something?
Here is an code example of how I was trying to get it done.
public Material material;
public VideoPlayer player;
public GameObject screen;
private bool flat = false;
void Update(){
if (flat)
{
flat = false;
screen.SetActive(false);
player.renderMode = VideoRenderMode.RenderTexture;
}
else
{
flat = true;
screen.SetActive(true);
player.renderMode = VideoRenderMode.MaterialOverride;
player.targetMaterialRenderer = screen.GetComponent<Renderer>();
}
if (player.renderMode == VideoRenderMode.RenderTexture)
{
RenderTexture texture = new RenderTexture((int)player.width, (int)player.height, 24);
player.targetTexture = texture;
material.mainTexture = texture;
}
}