5
\$\begingroup\$

I have imported hundreds of textures in my Unity project, and I'd like to create a material for each of them. This would obviously take a lot of time, so how would I go about doing this automatically?

These are just basic textures that I want to assign to albedo on the standard Unity 5 shader. No need for normal maps.

\$\endgroup\$

2 Answers 2

3
\$\begingroup\$

Scripts put in a folder named Editor affect Unity's editor, rather than running when you play the game. You can use this functionality to extend the capabilities of the editor, to run custom functions you create. For example, here's a script that adds a window with buttons for custom functions: http://wiki.unity3d.com/index.php?title=FindMissingScripts

You probably want a script that will loop through all selected textures or something. You can then use AssetDatabase.CreateAsset to create material assets, as explained here: http://answers.unity3d.com/questions/21457/is-it-possible-to-create-a-material-asset-from-a-s.html

\$\endgroup\$
1
\$\begingroup\$

If you extend AssetPostprocessor you can receive a callback(OnPostProcessTexture) when a texture import is completed.

You can use that entry point to automatically create a new material and assign the relative texture to it.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .