123456789101112131415161718192021 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class OpenWebCamaer : MonoBehaviour
- {
- public string deviceName;
- WebCamTexture camTexture;
- // Use this for initialization
- IEnumerator Start() {
- yield return Application.RequestUserAuthorization(UserAuthorization.WebCam);
- if(Application.HasUserAuthorization(UserAuthorization.WebCam)) {
- WebCamDevice[] devices = WebCamTexture.devices;
- deviceName = devices[0].name;
- camTexture = new WebCamTexture(deviceName, 400, 300, 12);
- transform.GetComponent<MeshRenderer>().material.mainTexture = camTexture;
- camTexture.Play();
- }
- }
- }
|