hey folk,
i have the issue, that a beloved utility script of mine, which i used for years now, stops working as expected. i use an editor script which deactivates a lot of, for my project, unneeded components from models at first import. for example:
private void OnPreprocessModel()
{
ModelImporter importer = assetImporter as ModelImporter;
Object asset = AssetDatabase.LoadAssetAtPath (importer.assetPath, typeof(Object));
if (!asset)
{
importer.materialImportMode = ModelImporterMaterialImportMode.None;
importer.animationType = ModelImporterAnimationType.None;
importer.importAnimation = false;
Debug.Log("Model Import: override import settings for: " + importer.assetPath);
}
}
the pre processor gets always called if a model is imported or reimported, by changing its settings for example. now my issue is, that the old way of asking if the model is new, or already exists in the asset database, doesnt work anymore with the current unity version.
in older versions the asset variable in the example got only assigned, if the asset already exists, so the if statement was only executed at new imports. now, it is always assigned, so every time i change a setting, override a model, or switch platform, it have to execute the hole function, otherwise it would never be called.
ot
i have tried a couple of different things, like asking, if there is already a meta file, but it seams that the new unity version creates this all before preprocession now.
here are some sources on how it works back in the days:
https://forum.unity.com/threads/first-asset-import.136393/
long story short, how can i differ between new and already existing models at import?
thank you for your time reading this and it would be great if you could help me out with this!