Limiting OnPreprocessTexture to Initial Import. Not also when 'Apply' is Clicked in the Inspector

I’m using OnPreprocessTexture() to save my team time by setting default values for our sprites and textures. For 90% of our images this works fantastically. The other 10% of the time we’ll need to go in and overwrite those values in the inspector after import.

Problem is that after you hit “Apply” it seems tha OnPreprocessTexture() runs again and overwrites any change done in the inspector.

Here’s the Editor script I’m working on in case you need some code to try it against: drag an image file into the project, then try to change it from a Sprite to a Texture, and click ‘Apply’ to see the behavior:

using UnityEditor;
using UnityEngine;
using System.Collections;

public class ImageImport : AssetPostprocessor {

	//Used this as documentation:
	//https://gist.github.com/kamend/6a6dd80b233079b6e101
	void OnPreprocessTexture () {
    	//Get the TextureImporter 
    	TextureImporter import = assetImporter as TextureImporter;


		//Set it to a Sprite
		import.textureType = TextureImporterType.Sprite;

		//Set to 1 pixel per unit
		import.spritePixelsPerUnit = 1;

		//Set to multiple since we're likely doing spritesheets
		import.spriteImportMode = SpriteImportMode.Multiple;

		//Make it not compress and look terrible
		import.filterMode = FilterMode.Point;
	}
}

For those who run across this in the future, the following answer really helped me out. The key is to do a check to see if there’s an asset currently at the assetPath of the new asset. If not, then you can do you’re processing:

Here’s the OnPreprocessTexture function I’m running:

void OnPreprocessTexture () {

	//Get the TextureImporter 
	TextureImporter import = assetImporter as TextureImporter;


	Object asset = AssetDatabase.LoadAssetAtPath(import.assetPath, typeof(Texture2D));

	if (!asset) {
		Debug.Log("NEW");
		
		//Set it to a Sprite
		import.textureType = TextureImporterType.Sprite;

		//Set to 1 pixel per unit
		import.spritePixelsPerUnit = 1;

		//etc.

	}
	else {
		Debug.Log("OLD");
	}
}