Hi I’m trying to preview my sprite icon when I change it in my custom editor. The problem is that I can’t seem to find a way to only display the selected sprite, I display the entire texture instead.
I assign the sprite texture as so:
icon.style.backgroundImage = new StyleBackground(sprite.texture);
Since StyleBackground does not take a sprite input I’m not sure how to display it.
There is also the scaleToFit problem I do not know how to solve for non-square sprites.
And I need to make sure it works with the custom sprites shapes made using the sprite editor (or by going Create → Sprites → …)
So right now I have:

But essentially I would like the same thing as displayed in the object picker:

Can anyone give me some advice?
I would also like to do the same for Prefabs

but I’m not even sure where to start.
Thank you for your time
