Under what conditions is OnPreprocessModel called?

I just dealt with an issue where someone was getting a bunch of meta files changing for no reason when they first cloned the git repository.

It turns out they had a AssetImportOptions script which calls OnPreprocessModel on every model.

Normally, OnPreprocessModel is supposed to be called just when you import a new model. I guess it's treating models added by Git as new models.

How does Unity distinguish newly imported models that it should call OnPreprocessModel on, from models that have already been imported so they can be left alone?

Since all the import settings are in the .meta file, I assumed it would use that, but it appears not to be the case. The Git repo includes the .meta files, but after cloning, Unity was running OnPreprocessModel on those assets anyways. And on the other hand, if I delete a .meta file, it creates a new default but does not call OnPreprocessModel on it.

So where is Unity keeping track of what assets have already been imported, so I can ensure that data is included in the Git repository?

Is anyone familiar with how the OnPreprocessModel works and what conditions lead to it running?

Bump, I have the same question!

I'm going to hazard a guess that it only checks whether the artifact for that model exists in the Library (e.g.: has it already been imported on this local project instance).

In this case, it seems pretty useless to me, for the exact workflow issue you mentioned in your original post.

I wonder if we could check if a meta file exists using the assetPath property and suffixing .meta, but I doubt Unity hasn't already created it by that point. I'll test and report back.

Any confirmation from a Unity employee would be very welcome!

Found the solution!
You need to check ModelImporter.importSettingsMissing.
See this thread: https://discussions.unity.com/t/476477