打开相机

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/Exclaiming/article/details/80357545
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;
    }
}

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

私密
私密原因:
请选择设置私密原因
  • 广告
  • 抄袭
  • 版权
  • 政治
  • 色情
  • 无意义
  • 其他
其他原因:
120
出错啦
系统繁忙,请稍后再试