[Unity3D]unity3d5.0简单的调用摄像头
生活随笔
收集整理的這篇文章主要介紹了
[Unity3D]unity3d5.0简单的调用摄像头
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
Unity3D中新建一個(gè)工程,加一個(gè)Plane,新建一個(gè)C# 腳本,將這個(gè)腳本添加到Plane上,調(diào)用攝像頭。(如果顯示的圖片居然是翻轉(zhuǎn)的,Plane的Rotation 值就可以了)
以下是腳本內(nèi)容:
using UnityEngine; using System.Collections;public class C : MonoBehaviour {WebCamTexture webcamTexture;// Use this for initializationvoid 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 framevoid Update () {} }
?
轉(zhuǎn)載于:https://www.cnblogs.com/lyggqm/p/4346586.html
創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎(jiǎng)勵(lì)來(lái)咯,堅(jiān)持創(chuàng)作打卡瓜分現(xiàn)金大獎(jiǎng)總結(jié)
以上是生活随笔為你收集整理的[Unity3D]unity3d5.0简单的调用摄像头的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: sqlite mysql pgsql_比
- 下一篇: 空间曲线及其方程