Skip to content

Instantly share code, notes, and snippets.

@neon-izm
Created November 4, 2015 15:26
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save neon-izm/d55ff799b59981bf47fa to your computer and use it in GitHub Desktop.
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