查看: 559|回复: 0
打印 上一主题 下一主题

[其他] unity3d调用手机或电脑摄像头

[复制链接]

2722

主题

42

听众

3万

积分

资深设计师

Rank: 7Rank: 7Rank: 7

纳金币
38266
精华
111

最佳新人 活跃会员 热心会员 灌水之王 突出贡献

跳转到指定楼层
楼主
发表于 2015-2-28 23:08:36 |只看该作者 |倒序浏览

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 () {

}
}

分享到: QQ好友和群QQ好友和群 腾讯微博腾讯微博 腾讯朋友腾讯朋友 微信微信
转播转播0 分享淘帖0 收藏收藏0 支持支持0 反对反对0
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

关闭

站长推荐上一条 /1 下一条

手机版|纳金网 ( 闽ICP备08008928号

GMT+8, 2024-4-30 17:31 , Processed in 0.081666 second(s), 29 queries .

Powered by Discuz!-创意设计 X2.5

© 2008-2019 Narkii Inc.

回顶部