- Home /
WebCamTexture zoomed in on iPad Pro
I want to display camera preview on a plane. I am using WebCamTexture for it, but the output is zoomed in when compared to the Camera application on iPad Pro. I tried changing the resolution and setting a higher resolution too but the out put was same. I tried it on iPad 2 and still the output was zoomed in when compared to the Camera app.
Here is my code.
WebCamDevice[] devices = WebCamTexture.devices;
if (devices.Length > 0) {
WebCamTexture webcam = new WebCamTexture (devices [0].name,Screen.currentResolution.height,Screen.currentResolution.width);
if (!webcam.isPlaying) {
this.GetComponent<Renderer> ().material.mainTexture = webcam;
this.transform.GetChild(0).GetComponent<Renderer> ().material.mainTexture = webcam;
webcam.Play ();
}
}
Is there any way to get the texture to look normal and not zoomed in?
Any help on this would be appreciated. Thanks in advance.
Are not the constructor values (width and height) inverted? I guess it's deviceName, width, height respectively.
Answer by Shidz · Jan 08, 2018 at 09:57 AM
@Navtek , check out this post, it has alot of useful information i used. https://answers.unity.com/questions/773464/webcamtexture-correct-resolution-and-ratio.html
I had the same problem and i suspected the scaling of the webcam texture was off so i used
Material.SetTextureScale("_Texture", new Vector2(1f, 1f))
to set it back to its original scale and it worked for me.