Created
March 24, 2017 20:13
-
-
Save momo-the-monster/7286b118d393be0172e1aaa77135e676 to your computer and use it in GitHub Desktop.
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
public static WebCamTexture PrepareWebCamTexture (ref WebCamDevice device, bool frontFace, int width, int height) | |
{ | |
WebCamTexture texture = null; | |
// Checks how many and which cameras are available on the device | |
for (int cameraIndex = 0; cameraIndex < WebCamTexture.devices.Length; cameraIndex++) { | |
if (WebCamTexture.devices [cameraIndex].isFrontFacing == frontFace) { | |
Debug.Log (cameraIndex + " name " + WebCamTexture.devices [cameraIndex].name | |
+ " isFrontFacing " + WebCamTexture.devices [cameraIndex].isFrontFacing); | |
device = WebCamTexture.devices [cameraIndex]; | |
texture = new WebCamTexture (device.name, width, height); | |
break; | |
} | |
} | |
// fallback | |
if (texture == null) { | |
device = WebCamTexture.devices[0]; | |
texture = new WebCamTexture (device.name, width, height); | |
} | |
Debug.Log ("width " + texture.width + " height " + texture.height + " fps " + texture.requestedFPS); | |
return texture; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment