using UnityEngine;
using System.Collections;

public class C : MonoBehaviour
{
    private WebCamTexture cameraTexture;
    private string cameraName = "";
    private bool isPlay = true;
    // Use this for initialization  
    void Start()
    {
        cameraTexture = new WebCamTexture();
        StartCoroutine(Test());
    }

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

    }

    IEnumerator Test()
    {
        yield return Application.RequestUserAuthorization(UserAuthorization.WebCam);
        if (Application.HasUserAuthorization(UserAuthorization.WebCam))
        {
            WebCamDevice[] devices = WebCamTexture.devices;
            cameraName = devices[0].name;
            cameraTexture = new WebCamTexture(cameraName, 400, 300, 15);
            cameraTexture.Play();
            isPlay = true;
        }
    }

    void OnGUI()
    {
        if (isPlay)
        {
            GUI.DrawTexture(new Rect(0, 0, 400, 300), cameraTexture, ScaleMode.ScaleToFit);
        }
    }
}

 

unity3d 读取usb摄像头

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-12-09
  • 2022-12-23
  • 2022-01-01
  • 2022-01-01
  • 2021-05-01
  • 2021-10-28
猜你喜欢
  • 2021-06-11
  • 2021-11-21
  • 2021-07-18
  • 2022-12-23
  • 2021-06-19
  • 2021-11-28
  • 2022-01-20
相关资源
相似解决方案