u3d的摄像头:WebCamTexture

来源:互联网 发布:ip摄像头破解软件 编辑:程序博客网 时间:2024/06/07 09:41
OpenCamera的调用不要放在Awake中

void Start(){        StartCoroutine(<span style="font-family: Arial, Helvetica, sans-serif;">OpenCamera</span>());}IEnumerator OpenCamera()    {        yield return Application.RequestUserAuthorization(UserAuthorization.WebCam);//授权        if (Application.HasUserAuthorization(UserAuthorization.WebCam))        {            WebCamDevice[] devices = WebCamTexture.devices;            if (devices.Length <= 0)            {                Debug.Log("你的设备没有摄像头!!!");                isOpneCam = false;                yield break;            }            isOpneCam = true;            string deviceName = devices[0].name;            // 宽高互换            camTex = new WebCamTexture(deviceName, (int)(Screen.height), (int)(Screen.width), 12);            camTex.Play();//开始摄像            rimg_ShowCamera.texture = camTex;                   }        yield return null;    }
0 0