Пример #1
0
    /// <summary>
    /// 初始化摄像头
    /// </summary>
    private IEnumerator Start()
    {
        yield return(Application.RequestUserAuthorization(UserAuthorization.WebCam));

        if (Application.HasUserAuthorization(UserAuthorization.WebCam))
        {
            WebCamDevice[] devices = WebCamTexture.devices;
            //MessageBox.Show(devices.Length.ToString());
            if (devices.Length > 0)
            {
                //读取前置摄像头
                DeviceName      = devices[0].name;
                _webCamera      = new WebCamTexture(DeviceName, (int)CameraSize.x, (int)CameraSize.y, (int)CameraFPS);
                Texture.texture = _webCamera;
                _webCamera.Play();
            }
        }
    }