Created
November 4, 2015 15:26
-
-
Save neon-izm/d55ff799b59981bf47fa to your computer and use it in GitHub Desktop.
Thetaの再生用
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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