zoukankan      html  css  js  c++  java
  • Unity3D调用摄像头

    代码启用摄像头
    1.using UnityEngine;  
    2.using System.Collections;  
    3.  
    4.public class WebCamManager : MonoBehaviour {  
    5.  
    6.    // Use this for initialization  
    7.    void Start () {  
    8.  
    9.        WebCamTexture webcamTexture = new WebCamTexture ();  
    10.  
    11.        //如果有后置摄像头,调用后置摄像头  
    12.        for (int i = 0; i < WebCamTexture.devices.Length; i++) {  
    13.            if (!WebCamTexture.devices [i].isFrontFacing) {  
    14.                webcamTexture.deviceName = WebCamTexture.devices [i].name;  
    15.                break;  
    16.            }  
    17.        }  
    18.  
    19.        Renderer renderer = GetComponent<Renderer>();  
    20.        renderer.material.mainTexture = webcamTexture;  
    21.        webcamTexture.Play();  
    22.    }  
    23.  
    24.}  
    
    
    
     
    此博客出自TaoHu,转载请注明原文地址 | 博客地址:http://www.cnblogs.com/htwzl/ | -- Unity3D 学习交流 --
  • 相关阅读:
    HDOJ 1069_大二写
    HDOJ 2037:今年暑假不AC_大二写
    第二次HDOJ:1058
    HDOJ 1019
    第二次 HDOJ 1003
    第二次做HDOJ 1051
    memset()的用法
    数据结构中的频度含义
    程序框图的书写
    python课堂整理22----装饰器进阶
  • 原文地址:https://www.cnblogs.com/htwzl/p/7133457.html
Copyright © 2011-2022 走看看