Instantly share code, notes, and snippets.

Embed
What would you like to do?
Thetaの再生用
using UnityEngine;
using System.Collections;
public class WebCamScript : MonoBehaviour
{
public int Width = 1920;
public int Height = 1080;
public int FPS = 60;
public string CameraName="";
void Start()
{
var devices = WebCamTexture.devices;
for (int i = 0; i < devices.Length; i++)
{
if (devices[i].name.Contains("THETA") || devices[i].name.Contains("USB Camera"))
{
CameraName = devices[i].name;
}
}
if (devices.Length>0)
{
if (CameraName == "")
{
CameraName = devices[0].name;
}
var webcamTexture = new WebCamTexture(CameraName,Width, Height, FPS);
GetComponent<Renderer>().material.mainTexture = webcamTexture;
webcamTexture.Play();
}
else
{
Debug.Log("Webカメラが検出できませんでした");
return;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment