当前位置: 移动技术网 > IT编程>开发语言>c# > unity3d调用手机或电脑摄像头

unity3d调用手机或电脑摄像头

2019年07月18日  | 移动技术网IT编程  | 我要评论

功能很实用,代码很简单,这里就不多废话了。

webcamtexture:网络摄像头材质
webcamtexture.play()  播放;
webcamtexture.pause()  暂停;
webcamtexture.stop()  停止;
//经测试此代码可以使用,当你绑定到游戏物体时尽可以了、
using unityengine;
using system.collections;
public class test : monobehaviour {
public string devicename;//这个虽然public,但无需为其绑定变量,直接运行,默认调用,显示本地摄像机的名称
webcamtexture webcam;
 
 
// use this for initialization
void start () {
 webcamdevice[] devices = webcamtexture.devices;
 devicename = devices[0].name;
 webcam = new webcamtexture(devicename, 400, 300, 12);
 renderer.material.maintexture = webcam;
 webcam.play();
}
 
// update is called once per frame
void update () {
 
}
}

以上所述就是本文的全部内容了,希望大家能够喜欢。

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网