Sprite internal mesh

Hi,

The release notes state: “Sprite has an internal mesh generated based on pixel alpha values, PRO only feature.”

I’ve noticed Unity doing this automatically, however, it seems I have no control over it! I want to be able to turn it off completely for some sprites, where I am using a custom shader where the alpha channel is not transparency (a fairly common thing to do, really!) but Unity is automatically creating a ridiculous mesh cutting out all parts of the image that have low alpha values. Also, it sometimes crashes on import because it’s trying to create a mesh with greater than 65535 tris.- but I sure didn’t tell it to try.
Any solutions? Er, besides downgrading to Unity Free?

EDIT: I found that the “Advanced” mode of the texture importer has a “Sprite Mode” which can be set… but even after this is set to Single and re-imported, Unity doesn’t seem to consider it a Sprite. That is, it can’t be dragged onto a Sprite Renderer. Bug? The only things I can drag onto a Sprite Renderer are regular (non-advanced) Sprites.

EDIT 2: Advanced mode works if and only if the texture has previously been imported as a simple Sprite. I guess that is the work-around for now, but this is clearly a bug and has now been reported.

Texture Type = Advanced
Sprite Mode = Single or Multiple
Mesh Type = Full Rect

This always gives you quad

Thank you; but please note the bug mentioned above - it is impossible to do a first-time import of a Sprite Mode (Single or Multiple) when Texture Type is set to Advanced. One first has to import as a regular Sprite (non-advanced).

In some cases even the workaround of doing a simple Sprite import first doesn’t work because the importer crashes trying to make a huge mesh with too many triangles in this first step. This can be shown by trying to import a 2048x2048 texture that has random noise in the alpha channel (so Unity makes a zillion tris around all the random alpha pixels).

1 Like

You can alter texture import default by changing editor behavior mode.

3D behavior mode: Defaults to Texture
2D behavior mode: Defaults to Sprite

Find it from: Main Menu → Edit → Project Settings → Editor

Is avoiding the crash the only reason you need to affect “first-time import”?

Maybe this will help: http://docs.unity3d.com/Documentation/ScriptReference/AssetPostprocessor.html

Thanks Keely. When I say the first-time import in Advanced mode is impossible, I didn’t mean that I don’t know how to do so - I mean that Unity doesn’t properly create the Sprite child asset (that can be used on a Sprite Renderer) unless the image is first imported in regular (simple) Sprite mode. Trying to import it for the first time set to Advanced type and one of the Sprite Mode settings on, doesn’t create the sprite as one would expect. Clearly a bug. It does update the sprite when in this mode if the image has previously been imported in simple Sprite mode.

I tried to reproduce this bug, but for me it works. If I go from normal texture to advanced and set it to Sprite Mode = Single, it generates the sprite child asset.

However, I noticed that by default the texture seems to have Non Power of 2 = ToNearest. If you try to apply Sprite Mode = Single without changing that, it will give you warning in the console: “Sprites can not be generated from textures with NPOT scaling”. Maybe this is what is happening to you too?

No, the textures I’m working with are 2048x2048 so NPOT options are disabled anyway. I don’t get any error messages, it just imports it as a regular Texture2D (rather than a Sprite). That’s very strange that it isn’t reproducible on your end. Thanks for trying, though.

Maybe something to do with the image in question. Can you attach such image so I can test?

It’s a PSD which can’t be attached. I don’t have server space at the moment - could you PM me an email address I could send it to?
Thanks again.

Hi guys, just letting you know that it’s 2015 and that bug about using a texture set as advanced sprite not working unless you use it first as a standard sprite, is still there. I get the console message “Texture being dragged has no Sprites”.

1 Like