How does sprite extrude edges work?

How exactly does sprite extrude edges work? Whether I set it to 0 or to Max it doesn't seem to do anything different.

Does anyone know how to use this feature properly and what problem it is designed to solve?

Hello madGlory,

The "Extrude Edges" option represents "How much empty area to leave around the sprite in the generated mesh."

You can check in more depth how exactly works in the Unity's C# reference files: https://github.com/Unity-Technologies/UnityCsReference/blob/master/Editor/Mono/ImportSettings/TextureImporterInspector.cs

Happy learning!

So the application that I was trying to use it for is drawing a border around a sprite. I wrote a simple shader to test out if anything was being affected by the value. The shader frag function simply returns white.

The result appears to be the exact same size with extrude edges width of 0 and of 32. I attached 2 photos, the first is the border width of 0 and the second is 32. Maybe I'm understanding wrong but I was under the impression that the generated mesh size would affect the draw area of the shader?

I was hoping to use the extrude edges to add more draw space for a custom outline shader that I was working on which is currently being cut off. It would be much easier to extrude the edges of all of my sprites than it would be to change the real size and reimport all 300 of them. But the feature seems to be doing nothing for me. Am I missing a key piece of information?

5719417--599245--Screen Shot 2020-04-16 at 12.29.47 AM.png
5719417--599248--Screen Shot 2020-04-16 at 12.29.29 AM.png

Did you ever find a solution to this?

I really want to know the answer as well! I'm having a similar problem.

No nothing yet, I filed a bug report and Unity responded by saying everything was working normally which doesn't appear to be the case as the extrude edges function is clearly not affecting the sprite at all.

I sent back a video showing the issue as clearly as possible and am now awaiting a reply.

I just got a reply from unity saying this:

"It seems that the Sprite is not affected by the option because its full rect already takes up all the texture. The developer told me that Extrude Edges essentially extends the Sprite’s Mesh to the surrounding alpha pixels. The workaround would be to make the Texture bigger by adding some alpha pixels and then using the Extrude Edges option to determine how far to extrude the edge of the Texture."

Considering we have 300+ sprites in our game, adding white space to all of them is not a simple solution.

Not quite sure where to go from here.

2 Likes

I'm facing the exact same problem building a custom outline shader on sprites coming from sprite sheets with no gap. I know I necro this post, but were you able to find a quick (scripted?) solution to this issue ?

Even if you didn't find a solution, I would be more than happy to know what you did to solve this

Extrude Edges option value should be respected also when generating the custom outline in the sprite editor.
The option is completely ignored if clicking generate making the extrude edge option useless in such case. The reason why we want to use generate custom outline is to control how fine the mesh becomes according to the details, but there is no option to extend or control the gap when "generating" the custom outline making these two options conflicts each other and making them useless to use both of them together. Such a disappointment.

This is yet another classic case of "there is this feature" in the Unity but not very practically thought of when actually making a real game.