private void _updateScreen() { int size = SCREEN_WIDTH * SCREEN_HEIGHT * 4; byte[] bytes = new byte[size]; IntPtr pointer = getBytes(); Marshal.Copy(pointer, bytes, 0, size); Color32[] pixels = _screenBuffer.pixels; int width = _screenBuffer.width; int i = 0; for (int y = 0; y < SCREEN_HEIGHT; y++) { for (int x = 0; x < SCREEN_WIDTH; x++) { int index = x + y * width; pixels[index].r = bytes[i + 2]; pixels[index].g = bytes[i + 1]; pixels[index].b = bytes[i + 0]; pixels[index].a = 255; i += 4; } } _screenBuffer.Update(); }