| 这个拉伸可能只是我有的问题。。。先记录一下 首先检测有没有摄像机的权限安卓平台:Permission.HasUserAuthorizedPermission(Permission.Camera)
 ios:Application.HasUserAuthorization(UserAuthorization.WebCam)
 但是这里我有个问题,哪位大神能告诉我下,为啥安卓检查的这个方法要是IEnumerator,我 void就不行。。。 也没啥返回值啊          string deviceName = cameraDevices[0].name;
         
            camTexture = new WebCamTexture(deviceName);
            showImage.canvasRenderer.SetTexture(camTexture);
            camTexture.Play();
            webCamTexture = camTexture;
 问题就是showImage的大小 不能是ui自适应的屏幕大小,应该根据相机的尺寸去设置。 
float  cameraSizeRatio = (float)camTexture.width / (float)camTexture.height;
float screenRatio = (float)UnityEngine.Screen.width / (float)UnityEngine.Screen.height;
if (cameraSizeRatio < screenRatio)
{
	showImage.GetComponent<RectTransform>().sizeDelta = new Vector2(UnityEngine.Screen.width, UnityEngine.Screen.height * screenRatio / cameraSizeRatio);
}
else
{
	showImage.GetComponent<RectTransform>().sizeDelta = new Vector2(UnityEngine.Screen.width / screenRatio * cameraSizeRatio, UnityEngine.Screen.height);
}
 就不拉伸了 |