首页 > 编程语言 > 详细

[ Unity3D]unity3d5.0简单的调用摄像头

时间:2015-03-18 12:04:20      阅读:468      评论:0      收藏:0      [点我收藏+]

Unity3D中新建一个工程,加一个Plane,新建一个C# 脚本,将这个脚本添加到Plane上,调用摄像头。(如果显示的图片居然是翻转的,Plane的Rotation 值就可以了)

以下是脚本内容:

using UnityEngine;
using System.Collections;

public class C : MonoBehaviour 
{
    WebCamTexture webcamTexture;
    // Use this for initialization
    void Start () 
    {
        WebCamDevice[] devices = WebCamTexture.devices;
        if (devices.Length > 0)
        {
            webcamTexture = new WebCamTexture(devices[0].name, 320, 240, 25);
       //renderer.material.mainTexture
= webcamTexture;
        //这里和之前版本不一样了
        GetComponent<Render>()
.material.mainTexture = webcamTexture;
            webcamTexture.Play();
        }
    }
    
    // Update is called once per frame
    void Update () 
    {
    
    }
}

 

[ Unity3D]unity3d5.0简单的调用摄像头

原文:http://www.cnblogs.com/lyggqm/p/4346586.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!