-1

I tried many ways to do this, Want to show a bitmap in a Unity image(UI) tried all the ways I can find. I can do it by saving the file to disk and then reading it but that's too costly as it needs to be done in every frame.

I checked image is loaded correctly but the problem is in converting to Texture2D and also saving it to memory stream and reading the file also crashes unity, I tried in Unity 2017 2018 2019 all crashes

tried all this ,this

*Only need to make this work in desktop Build if it helps

    Bitmap bitmap = new Bitmap(@"C: \image1.jpg");    
    final = UnmanagedImage.FromManagedImage(bitmap);
    Texture2D convertedTx;
    convertedTx = Texture2D.CreateExternalTexture(final.Width, final.Height, TextureFormat.ARGB32, false, false, final.ImageData);
    //Convert UnmanagedImage to Texture
    convertedTx.UpdateExternalTexture(final.ImageData);       
    display.texture = convertedTx;
Maulik Lathiya
  • 153
  • 3
  • 14

1 Answers1

-1

I think you didn't put this code in an enumeration, so its run on the main thread and cause unity crash