unity调用手机摄像头
核心知识:WebCamTexture(网络摄像头材质)
关键方法:WebCamTexture.Play()播放;WebCamTexture.Pause()暂停;WebCamTexture.Stop()停止;
public WebCamTexture webCamTexture;
public Material webCamMaterial;
IEnumerator webCam(){
yield return Application.RequestUserAuthorization(UserAuthorization.WebCam);
if (Application.HasUserAuthorization(UserAuthorization.WebCam))
{
WebCamDevice[] devices = WebCamTexture.devices;
deviceName = devices[0].name;
tex= new WebCamTexture(deviceName, 400, 300, 12);
webCamShow.mainTexture=tex;
tex.Play();
}
}