OnPreprocessModel() override for individual changes???

So I can’t figure out a way around this, and even though it has been talked about already, I never found a fix to this problem.

I am using the following code to process my fbx files on import:

using UnityEditor;
using UnityEngine;

public class FBXImportSettings : AssetPostprocessor {

	void OnPreprocessModel () {

		ModelImporter modelImporter = assetImporter as ModelImporter;

		modelImporter.globalScale = 1;
		modelImporter.addCollider = true;
		modelImporter.generateAnimations = ModelImporterGenerateAnimations.None;
		modelImporter.normalImportMode = ModelImporterTangentSpaceMode.Import;

		Debug.Log("Importing model at: " + assetPath);
	}
}

Works like a charm except it won’t let me manually change settings…every time I change an import setting manually in the FBXImporter options, it reverts it back to the above values when I press ‘Apply’.

Is there a way to prevent this from happening?

Thanks for your time and help,

Stephane

I’m not sure if there’s an official way to do this, but here’s a solution that definitely works.

Add a label to any asset where you want to override your AssetPostProcessor’s defaults. To add a label, look at the bottom of the inspector for an ellipsis in a little blue button. Click it to add a label, something like “importoverride”. Then, do the following in the asset processor script.

void OnPreprocessModel() {
	List<string> labels = new List<string>(AssetDatabase.GetLabels(assetImporter));
	if(!labels.Contains("importoverride")) {
		// Do default processing behavior
	}
}

If more advanced behavior were needed, you could add any number of labels to control the import process per asset.