Search Issue Tracker


Fixed in 2022.3.23f1, 2023.2.17f1, 6000.0.0b14



Found in




Issue ID




WebCamTexture.GetPixels32 returns black pixels when in WebGL Player



Reproduction steps:
1. Open the “WebcamGetPixels32“ project
2. Open the “Sample” scene
3. Ensure a webcam device or a virtual camera is connected
4. Ensure WebGL is the selected platform in Build Settings
5. Build And Run
6. Observe the middle of the Player

Expected result: Webcam feed is visible
Actual result: Black pixels are visible instead of the webcam feed

Reproduced in: 2022.2.0a12, 2022.3.7f1, 2023.1.9f1, 2023.2.0b4
Not reproduced in: 2021.3.29f1, 2022.2.0a11

Reproduced on: macOS 13.4.1 (Intel), Windows 10
Not reproduced on: No other environment tested

Note: Not reproduced in Play Mode and Windows Player, while OSX Player failed to build

Comments (6)

  1. Nyro

    Jan 16, 2024 23:50

    So, there is a Terrible work around.
    Blit the texture from the camera to a rendertexture > convert it to Texture2D > GetPixels32 from this Texture2D

    Does this work - Yes
    Is it performant - Hell no!
    Should you do it - how desperate are you?

    var rdTexture = new RenderTexture(camTexture.width, camTexture.height, 0);
    Graphics.Blit(camTexture, rdTexture);
    texture2D = ToTexture2D(rdTexture);
    var pixelData = texture2D.GetPixels32();

    public Texture2D ToTexture2D(RenderTexture rTex)
    Texture2D tex = new Texture2D(rTex.width, rTex.height, TextureFormat.RGB24, false);
    var old_rt =; = rTex;

    tex.ReadPixels(new Rect(0, 0, rTex.width, rTex.height), 0, 0);
    tex.Apply(); = old_rt;
    return tex;

  2. Tonio1308

    Dec 21, 2023 05:55

    We have the same problem in our 2023.2.2 WebGL project.
    We need webCamTexture GetPixels32() as soon as possible.
    Thank you

  3. faleoc

    Dec 18, 2023 05:09

    I have the same issue, which blocked my project.

  4. ChengruRa

    Dec 05, 2023 10:15

    Using Unity version 2021.3.32f1 can solve this issue, while versions 2022 and 2023 both result in black pixels.

  5. CameronGoosen

    Oct 06, 2023 07:40

    I'm having this issue on WebGL, I've tried everything to get around this issue, even tried to bypass the GetPixels32 with this code which works on editor:

    var tex2D = new Texture2D(webCamTexture.width, webCamTexture.height, TextureFormat.ARGB32, false);

    Graphics.CopyTexture(RawImage.texture, tex2D);

    but it seems that its broken entirely, it still only returns black pixels and you'll probably only be able to get the image if you make your own Javascript plugin.

  6. nigorigori

    Oct 01, 2023 09:04

    This issue is very critical in the app I am currently creating and I hope it will be fixed ASAP.

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.