Страница 1 из 1

Unity. WebCamera enable and set preferences

СообщениеДобавлено: 31 янв 2015, 23:19
T I N T A F

Синтаксис:
Используется csharp
using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class WebCamScript : MonoBehaviour {
   
    private RawImage rawimage;

    public GameObject image;

    public void Awake()
    {
        rawimage = image.GetComponent<RawImage>();
    }

    public void Start()
    {
        WebCamDevice[] webcamdevices = WebCamTexture.devices;
        WebCamTexture webcamtexture = new WebCamTexture();

        if (webcamdevices.Length > 0)
        {
            webcamtexture.deviceName = webcamdevices[1].name;
            webcamtexture.Play();
            rawimage.texture = webcamtexture;
        }
    }
}