本文介绍了统一Android的前置摄像头WTF的bug的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发使用Unity Android版的应用程序。
尝试使用前置摄像头,从WebCamTexture获取数据。后置工作正常,但是当我尝试翻转相机这个可怕的事情出来:

I'm developing an app for Android using Unity.Trying to use front facing camera, getting data from WebCamTexture. Rear-facing works fine, but when I try to flip the camera this awful thing comes out:

**bitstream == (int)0xAFAFAFAF

作为统一的控制台错误。然后,WebCamTexture停止工作可言,甚至与后置摄像头。
你知道吗?

as an error in the unity console. Then, WebCamTexture stops working AT ALL, even with the rear-facing camera.Any idea?

P.S。使用Unity 5.3.3p1 ......可能是一个团结的错误?

P.S. using Unity 5.3.3p1... could be a Unity bug?

推荐答案

任何人看书,一个新的(2016年)的插件已经出现了团结,

NOTE

for anyone reading, a new (2016) plugin has appeared for Unity,

基本上你必须让这个如果你想使用统一的设备的摄像头。

basically you "have to get this" if you want to use device camera in Unity.

Unity的设备摄像头的东西是团结的最糟糕的事情 - 这是字面上也不阿尔法质量。这是在Unity最糟糕的事情,这是荒谬的,他们包括它,它只是一个试运行。

Unity's device-camera stuff is the worst thing in Unity - it's literally not even alpha quality. It's the worst thing in Unity and it's ridiculous they included it, it's just a test run.

这是非常难写一个双平台真正的原生,高速摄像机插上。现在,第一个出现有没有真正的替代,而不是使用它。 Unity的废话是不可能的,你可以很容易地花2-3周试图获得一个粗略的摄像头的工作。

it's extremely difficult to write a dual-platform true native, high-speed camera plug in. Now that the first one has appeared there's no real alternative than to use it. Unity's crap is impossible and you can easily spend 2-3 weeks trying to get a rough camera working.

下面是一个相当bulletroof改变相机的灾难的方法!

Here's a fairly bulletroof approach for the disaster of changing cameras!

public void CycleCams()
        {
        StartCoroutine(_cycle());
        }

    private IEnumerator _cycle()
        {
        WebCamDevice[] d = WebCamTexture.devices;
        if ( d.Length <= 1 )
            {
            Debug.Log("only one.");
            if (d.Length==1) Debug.Log("Name is " +d[0].name);
            yield break;
            }

        Debug.Log("0 " +d[0].name);
        Debug.Log("1 " +d[1].name);

        if ( wct.deviceName == d[0].name )
            {
            wct.Stop();
            yield return new WaitForSeconds(.1f);
            wct.deviceName = d[1].name;
            yield return new WaitForSeconds(.1f);
            wct.Play();

            nameDisplay.text = "\"" +wct.deviceName +"\"";
            yield break;
            }

        if ( wct.deviceName == d[1].name )
            {
            wct.Stop();
            yield return new WaitForSeconds(.1f);
            wct.deviceName = d[0].name;
            yield return new WaitForSeconds(.1f);
            wct.Play();

            nameDisplay.text = "\"" +wct.deviceName +"\"";
            yield break;
            }
        }

这篇关于统一Android的前置摄像头WTF的bug的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-02 23:30