TArray<FColor> to UTexture issue in Xbox

Hi everyone, I’m currently getting the last rendered frame and passing it to a UTexture, this currently works fine on a build for PC and in-editor, but in xbox it breaks, it kind of “tiles” the image on the x axis, it’s not really a tile bc each part is different. Here’s the code I’m currently using:

void UScreenshotToTexture::CallbackScreenShot(int32 InWidth, int32 InHeight, const TArray<FColor>& InColors) {
      if(!MainTexture || InWidth != MainTexture->GetSizeX() || InHeight != MainTexture->GetSizeY())
           MainTexture = UTexture2D::CreateTransient(InWidth, InHeight);
#if WITH_EDITORONLY_DATA
     MainTexture->MipGenSettings = TMGS_NoMipmaps;
#endif
     if(MainTexture) {
          MainTexture->CompressionSettings = TextureCompressionSettings::TC_Default;
          MainTexture->SRGB = 1;
          FTexture2DMipMap& Mip = MainTexture->GetPlatformData()->Mips[0];
          void* Data = Mip.BulkData.Lock(LOCK_READ_WRITE);
          constexpr int32 stride = static_cast<int32>(sizeof(uint8) * 4);
          FMemory::Memcpy(Data, InColors.GetData(), MainTexture->GetPlatformData()->SizeX * MainTexture->GetPlatformData()->SizeY * stride);
          Mip.BulkData.Unlock();
          MainTexture->UpdateResource();
     }
     SetTexture();
}

Probably a long shot, but I’ve seen this happen once so I may as well mention it. If you grab pixel data from a texture that has R, G and B all of the same values on a per pixel basis (ie grayscale), the texture can actually be converted to G8 automatically. So when you grab the pixels from it, you’re getting one quarter of the pixels you think you are. When you then copy it into a color buffer, it will actually tile.

When you fill in the TArray that you’re passing in, make sure the source texture is actually RGBA8 and not G8. Note this can happen if the first frame is all black or something, then it uses G8 and you’re stuck with it. Anyways, unlikely, but easy to check.