问:
Unity 3.5 release notes say there is support for the iOS Camera. Where is this documented?
I'm looking for a simple example of how to take a photo and apply it as a texture.
回答:
We were having a similar problem and got this reply from the great folks at Unity:
The cameras are accessed from the WebCamTexture class:-
http://unity3d.com/support/documentation/ScriptReference/WebCamTexture.html
When you create an instance of this class, you supply the name of the camera you want to use. A list of all cameras is available from the devices property. The entries in the list give the camera's name and whether or not it is front-facing. You could use code something like the following:-
function Start () { var devices : WebCamDevice[] = WebCamTexture.devices; var frontCamName: String; var backCamName: String; var frontTex: WebCamTexture; var backTex: WebCamTexture;
for( var i = 0 ; i < devices.length ; i++ ) { if (devices[i].isFrontFacing) { frontCamName = devices[i].name; } else { backCamName = devices[i].name; } } frontTex = new WebCamTexture(frontCamName, width, height, framesPerSec); backTex = new WebCamTexture(backCamName, width, height, framesPerSec);}
The WebCamTexture also has Play, Pause and Stop functions and GetPixels/SetPixels (like Texture2D) to enable you to analyse the captured image data.
I hope this helps address your question as far as accessing the cameras. -wm
本文档详细介绍了如何在Unity中使用iOS设备的摄像头。通过WebCamTexture类,您可以轻松地访问并使用摄像头来捕获图像,并将其作为纹理应用到Unity场景中。本文提供了具体的代码示例,展示了如何选择前后置摄像头,以及如何创建WebCamTexture实例。

1317

被折叠的 条评论
为什么被折叠?



