Unity preset manager filter

I have made specific presets for textures like Normal or Emission maps. After they are imported I have to manually select each one and assign the proper preset.

I want to automate this process. To do this Unity has preset filters:

The problem is I cant get the syntax to work. I have tried so many variations of the documentation examples, but nothing works.

Example:

Lets say I want every png file which ends in “_Normal” to get a specific preset value.

1 Like

Your example would be: glob:"*_normal.png"

I confirmed this to work in my project. However, also be aware that Unity presets are only applied for assets which don’t yet have import settings, or said differently, only the very first time it is imported. That would mean, if you rename an asset or change the assigned preset, you cannot expect the settings to be applied automatically, even if you context-click and reimport an asset. Instead, you have to apply the preset manually in this case, and to test the automatic preset manager assignment, delete a test asset and add a new one.

Thanks allot ! You saved me allot of headaches.
Yeah I know it works only on import.
Btw how did you figure that syntax out ? Did you look at my link from above ? Or is there some other place I can check how the syntax works (whatever it is even called) ?

Glad it works!

Yes I did, since there’s no way I could remember these things. It says in the docs to use the asterisk symbol to match 0 or more characters. Whereas the angled brackets indicate a range of characters (with a really weird syntax honestly). But don’t worry if you had trouble figuring it out, it’s unintuitive stuff and hard to test within Unity.

You can think of it like placeholder characters: *_normal.png means, replace the asterisk with any or no character, and it will match. So “MyTex_normal.png” is a match, but “MyTexnormal.png” is not. Even “_normal.png” is a match, but “_Normal.png” is not because its case-sensitive.

Yes, you could look up how Regex works, and get acqainted with it via online regex testers (just search, any will do). There you can input text and edit your search patterns with live feedback. Of course, Regex is not Glob and Unity most likely has a custom implementation of what they call Glob here. So you could also look up a tutorial on Glob syntax in general. In any case, it will help understand the basic principles of how these matches work and then you can come back to Unity and discover more easily how Unity implements the rules (always be aware that they might be a little different).

If you have more specific questions, feel free to ask, I might be able to explain how it works knowing how confusing it can be.

Aha I see. Yeah it is really unintuitive. The online regex thing is a good idea though. It would be useful If I get stuck on smth like that in the future.
Anyway thanks again for the help !

You can rerun the preset by using reset on the file.

The only problem I have is that Untity has indeed his own implementation on glob :frowning:
When I test on this tester it works but Unity glob doesn’t.
https://www.digitalocean.com/community/tools/glob?comments=true&glob=[Aa]ccessory__[Dd]*.[TtPp][GgSs][AaDd]&matches=false&tests=// This will match as it ends with ‘.js’&tests=/hello/world.js&tests=Tex_Accessory_M_Glasses_Round_Tortoiseshell_D_R.tga&tests=// This won’t match!&tests=/test/some/globs
glob = [Aa]ccessory__[Dd]*.[TtPp][GgSs][AaDd]
test string = Tex_Accessory_M_Glasses_Round_Tortoiseshell_D_R.tga

Is there any other way to do these preset without building your own tool?

I have also same issue.
https://forum.unity.com/threads/preset-manager-filter.1467914/
How can I solve it?