XRCameraImagePlane plane = image.GetPlane(0);               // use the Y plane
#else
        public static void GetPlaneDataFast(ref IntPtr pixels, XRCpuImage image)
        {
            XRCpuImage.Plane plane = image.GetPlane(0);                 // use the Y plane
#endif
            int width = image.width, height = image.height;

            if (width == plane.rowStride)
            {
                unsafe
                {
                    pixels = (IntPtr)NativeArrayUnsafeUtility.GetUnsafeBufferPointerWithoutChecks(plane.data);
                }
            }
            else
            {
                unsafe
                {
                    ulong  handle;
                    byte[] data   = new byte[width * height];
                    byte * srcPtr = (byte *)NativeArrayUnsafeUtility.GetUnsafeBufferPointerWithoutChecks(plane.data);
                    byte * dstPtr = (byte *)UnsafeUtility.PinGCArrayAndGetDataAddress(data, out handle);
                    if (width > 0 && height > 0)
                    {
                        UnsafeUtility.MemCpyStride(dstPtr, width, srcPtr, plane.rowStride, width, height);
                    }
                    pixels = (IntPtr)dstPtr;
                    UnsafeUtility.ReleaseGCObject(handle);
                }
            }
        }
            XRCameraImagePlane plane = image.GetPlane(0);               // use the Y plane
#else
        public static void GetPlaneData(out byte[] pixels, XRCpuImage image)
        {
            XRCpuImage.Plane plane = image.GetPlane(0);                 // use the Y plane
#endif
            int width = image.width, height = image.height;

            pixels = new byte[width * height];

            if (width == plane.rowStride)
            {
                plane.data.CopyTo(pixels);
            }
            else
            {
                unsafe
                {
                    ulong handle;
                    byte *srcPtr = (byte *)NativeArrayUnsafeUtility.GetUnsafePtr(plane.data);
                    byte *dstPtr = (byte *)UnsafeUtility.PinGCArrayAndGetDataAddress(pixels, out handle);
                    if (width > 0 && height > 0)
                    {
                        UnsafeUtility.MemCpyStride(dstPtr, width, srcPtr, plane.rowStride, width, height);
                    }
                    UnsafeUtility.ReleaseGCObject(handle);
                }
            }
        }