White Edges on Sprites Loaded from PNG at Run-time

When I use use Texture2D.LoadImage at run-time, I have white edges around my sprites that I don’t get if I load the same exact sprites in the Editor. I know this has to do with pre-multiply alpha and there are ways to pre-process the source image to avoid this, but the Editor does not have this issue and I would prefer not to have to do extra processing on all my images. Also, this is for a tool that allows users to select their own sprites, so I don’t have control over those images, nor do I want to explain some processing step to my non technical users.

I have seen a few other threads and unity answers posts regarding this, but the only thing I am seeing is source image processing which as mentioned above is not an option.

I have tried messing with the alpha settings on the texture to no avail. Is this some kind of limitation of run time texture/sprite loading or some setting I can fix? The editor handles these files perfectly, so I know Unity is at least capable of doing what I want on some level.

Thanks for any help!
(Unity 5.6.0p4)

Other similar issues:

http://answers.unity3d.com/questions/1237452/sprite-black-borders-on-imported-transparent-png-f.html

I’m having the same issue…

Use .PremultiplyAlpha() method

2 Likes

This works, but don’t forget to call Apply()!