By default, when you import a model in Unity, if a given material does not exist in the project yet, it is created in a local “Material” folder in the same directory as the model. I’d like to change this behavior to create the material in a very specific place.
I’m very familiar with the AssetPostprocessor, and my experiments have gotten me far enough to import the mesh (and also the material, so the material name is not overwritten with Default-Diffuse), then using the imported GameObject in OnPostprocessModel to derive the material names. From there it’s trivial to use the AssetDatabase to create and store new materials wherever I want. I then just delete the generated Materials folder in the local directory.
The problem is that there seems to be no way (that I can find) to create a symbolic link between the newly created material and the imported model- it will always show up as magenta/pink because it is still linked to the originally generated materials (which no longer exist).
Is there any way to establish a link between an imported model and a different material?
I’m trying to do something for our pipeline that I’m not sure is possible, so if anybody has any experience with this I’d be grateful for some assistance. And to stem off any “why bother?” comments, lets just say there’s a specific reason that I’m not at liberty to disclose for needing our pipeline to be this way and leave it at that ![]()