Modifying asset import options from script, confusing inconsistent behavior

Hey all,

So we have a custom import process which connects to our pipeline and imports assets into Unity. One part of that process, is while bringing in textures, it looks to see if the texture being brought in a a Normal map and if so, sets the importer options to flag it as such.

This appears to work but it is strangely inconsistent even on the exact same assets. For one user it will work as expected and for another it won’t.

I’m wondering if there is some step I am missing or a different way I should be doing this? Please ignore any possible typos in the code below, as I can’t copy paste to here.

// Aseet is first imported normally using AssetDatabase.ImportAsset() with the ForceSycnhcronous option.
TextureImporter importer = AssetImporter.GetAtPath(texturePath) as TextureImporter;
if (importer != null)
{
    importer.isReadable = true;
    if (texturePath.Contains("NORM_"))
    {
        importer.textureType = TextureImporterType.NormalMap;
    }
}
AssetDatabase.ImportAsset(texturePath, ImportAssetOptions.ForceUpdate);

Turns out this was actually a bug in our code, with diverging code paths. The above code works fine - when it actually runs :smile: