2

enter image description hereI can't even find this setting within the devices default camera app. In Unity I have an app which I am just using the WebCamTexture and displaying it on a quad. The back camera is fine. Full color but when I set it to front facing camera it is black and white like it is stuck in some sort of IR night vision mode.

Unity Version 2018.3.7 Device: Pixel 4 XL (doesn't work right) Pixel 2 XL (works correctly with color image)

Is there anything out there for unity that can fix this?

I have tried everything within the unity documentation but there is no settings for this.

IEnumerator initAndWaitForWebCamTexture(){
        isInitWaiting = true;

        devices = WebCamTexture.devices;
        webCams = new WebCamTexture[devices.Length];
        textures = new Texture[devices.Length];

        for (int i = 0; i < devices.Length; i++)
        {
            webCams[i] = new WebCamTexture();
            webCams[i] = new WebCamTexture(devices[i].name, Mathf.RoundToInt(requestResolution.x), Mathf.RoundToInt(requestResolution.y), 30);
            textures[i] = webCams[i];
            textures[i].wrapMode = TextureWrapMode.Repeat;

            if (useFrontCam)
            {
                if (devices[i].isFrontFacing)
                {
                    TargetCamID = i;
                }
            }
            else
            {
                if (!devices[i].isFrontFacing)
                {
                    TargetCamID = i;
                }
            }
        }
        if (TargetCamID > devices.Length - 1) TargetCamID = devices.Length - 1;

        texture = webCams[TargetCamID];
        webCams[TargetCamID].requestedFPS = 30;
        webCams[TargetCamID].Play();

        for (int i = 0; i < materials.Length; i++)
        {
            materials[i].mainTexture = textures[TargetCamID];
        }
        if (BackgroundQuad != null) BackgroundQuad.GetComponent<Renderer>().material.mainTexture = textures[TargetCamID];

        foreach (GameObject obj in targetMeshObjects)
        {
            obj.GetComponent<Renderer>().material.mainTexture = textures[TargetCamID];
        }

        if (textures.Length > 0)
        {
            webCamTexture = webCams[TargetCamID];
            int initFrameCount = 0;
            bool isTimeout = false;

            while (webCamTexture.width <= 16)
            {
                if (initFrameCount > timeoutFrameCount)
                {
                    isTimeout = true;
                    break;
                }
                else
                {
                    initFrameCount++;
                }
                yield return new WaitForEndOfFrame();
            }

            textureResolution = new Vector2(webCamTexture.width, webCamTexture.height);

            isFlipped = webCamTexture.videoVerticallyMirrored;

            isInitWaiting = false;
        }
        yield return null;
    }

Pixel 2 using the same code shows the camera correctly. So this has something to do with the Pixel 4's cameras but no one seems to have ran into this yet.

iiidefektiii
  • 163
  • 1
  • 12

0 Answers0