I’ve been working on this Windows app and was recently tasked to switch it over to WebGL.
Everything has been going smoothly except for the Webcam Resolution which I can’t seem to get working… I need a 16:9 resolution but no matter what I do it seems to default to 480 x 640.
Here’s my code that works in editor, windows and android builds:
public IEnumerator RefreshCamera()
{
if (camTexture != null)
{
Display.texture = null;
camTexture.Stop();
camTexture = null;
}
else
{
WebCamDevice device = WebCamTexture.devices[currentCamIndex];
camTexture = new WebCamTexture(device.name, 576, 1024, 24);
camTexture.requestedHeight = 576;
camTexture.requestedWidth = 1024;
camTexture.requestedFPS = 24;
Display.texture = camTexture;
camTexture.Play();
}
yield return new WaitForEndOfFrame();
}
While I am setting the requested resolution when setting the camTexture variable this does not work on any platforms and defaults to 480 x 640. The lines that follows however seem to do the trick on Windows, editor and android. WebGL just ALWAYS defaults to 480 x 640 no matter what I do…
I’ve seen on documentation that IOS does not support requestedHeight/requestedWidth but there’s no mention of WebGL to be found.
Help is greatly appreciated.
Thank you