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

public class TestRGB : MonoBehaviour
{
    public int index;
    int w = 1280;
    int h = 720;
    WebCamTexture RGBCamTexture;
    // Start is called before the first frame update
    void Start()
    {

        WebCamDevice[] devices = WebCamTexture.devices;

        if (devices.Length == 0)
        {
            Debug.Log("No webcam devices found.");
            return;
        }
        // ʹ�õ�һ�����õ�����ͷ�豸������Ը�����Ҫѡ�������豸��
        RGBCamTexture = new WebCamTexture(devices[index].name, w, h, 30);
        Debug.Log("��������ͷ" + devices[index].name);
        // ��ʼ����ͷ��׽
        RGBCamTexture.Play();
        if (this.GetComponent<RawImage>() != null)
        {
            this.GetComponent<RawImage>().texture = RGBCamTexture;
            this.GetComponent<RawImage>().transform.localEulerAngles = new Vector3(0, 0, 0);
        }
    }

}