打开相机

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class cameraView : MonoBehaviour
{

    public GameObject cameraViewPlan;

    public static Texture2D viewTexture;
    public static WebCamTexture viewTextureCamera;

    // Use this for initialization
    void Start()
    {

        WebCamDevice[] devices = WebCamTexture.devices;
        viewTextureCamera = new WebCamTexture("Logitech HD Webcam C310", 640, 480, 30);//更改相机名称
        viewTextureCamera.Play();


    }

    // Update is called once per frame
    void Update()
    {

        viewTexture = new Texture2D(viewTextureCamera.width, viewTextureCamera.height);
        viewTexture.SetPixels(viewTextureCamera.GetPixels());
        viewTexture.Apply();

        GetComponent<Renderer>().material.mainTexture = viewTexture;
    }
}

阅读更多
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/Exclaiming/article/details/80357545
文章标签: unity C# 打开相机
个人分类: unity
上一篇SocketException: 以一种访问权限不允许的方式做了一个访问套接字的尝试
下一篇Vuforia移除识别图后,模型还保留在原来的位置
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭
关闭