AssetImporter / External File Import help? [Solved]

Hey folks,

I’m currently trying to import some texture assets defined in an external file, during the material creation process in the AssetImporter.

So, the mesh has an additional file with a bunch of texture paths defined in it (in a location outside of the Assets directory), and during OnAssignMaterialModel(), I pull in the file paths from the additional file and copy the texture files over into the Assets directory.

Then I try and import them (using AssetDatabase.ImportAsset(projectLocalPath) and then AssetDatabase.LoadAssetAtPath (projectLocalPath)) so I can assign them to the relevant slots in the material.

However, it doesn’t appear to be possible to import textures at that point (LoadAssetAtPath just returns null)… they don’t appear to be imported until after my mesh.

Is there a way I can import the textures then and there, and get a Texture asset back to apply to the material?

If anyone’s interested, I stored the asset paths of all the textures I had to import during the OnAssignMaterialModel method, along with their material slot name and the material.

Then, I added OnPostprocessTexture and had it check the imported texture’s path against the stored ones. If it’s a match, then it inserts itself into the stored slot name of the stored material (and then removes that entry from the stored list).

Seems to work just fine :slight_smile: