Unity. WebCamera enable and set preferences
Добавлено: 31 янв 2015, 23:19
Синтаксис:
Используется 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;
}
}
}
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;
}
}
}