Editor event when Apply button is clicked?

I want to run a script every time the Apply button is clicked on a texture importer. Currently, from what I can tell, OnPreprocessTexture() is only called when a setting value has not been previously applied. So if you do the following:

  1. Set Max Size = 256
  2. Apply
  3. OnPreprocessTexture() is called.
  4. Set Max Size = 512
  5. Apply
  6. OnPreprocessTexture is called.
  7. Set Max Size = 256
  8. Apply
  9. OnPreprocessTexture is NOT called.

I’m wondering if there is a way to detect that #8 occurred?

Is OnPostprocessTexture called in that scenario? Otherwise, you might be stuck with the global “anything in the project has changed” callback which I can’t remember the exact delegate for this early in the morning.

OnPostprocessTexture gets called with the same pattern as OnPreprocessTexture.

I’m guessing this was the event you were thinking of? https://docs.unity3d.com/ScriptReference/ObjectChangeEvents.html

I think you’re looking for this? https://docs.unity3d.com/ScriptReference/AssetPostprocessor.OnPostprocessTexture.html

This should fire after the texture is saved and everything.

The behavior is the same for both OnPreprocessTexture() and OnPostprocessTeture().

Okay, what is your goal exactly? (No, detecting the Apply button is not possible and it is not a goal, it is a tool to achieve something, what is this goal? What are you trying to do?)

Maybe we can offer a better way doing it?

I want to do tests to check texture format settings (e.g. compression settings) when they are changed in the editor to enforce project standards.