Figure: Diagnostic workflow: Source change → Set necessary importer values → Verify finite processing
Figure: Diagnostic workflow: Source change → Set necessary importer values → Verify finite processing

Cause and mechanism

AssetPostprocessor runs custom work when Unity imports assets such as images. If that work changes files or settings and triggers another import, it can keep repeating. Skip changes when the input is already in the intended state, and check that the import process reaches a stable result.

Check and correct the setup

  1. Change only necessary importer properties in preprocess callbacks.
    First error, references and target environment
    First error, references and target environment
  2. Avoid recursively reimporting the same asset; write generated files only when their content changes.
    First error, references and target environment
    First error, references and target environment
  3. Control necessary batch reimports outside the callback and log paths/counts.
    First error, references and target environment
    First error, references and target environment

Limits and verification

SetDirty is not a universal import-loop remedy. Verify that a single source edit leads to finite processing.

A focused diagnostic setup

Limit the test to one image and log callback, path, before/after settings and invocation count. Check whether generated outputs feed back into inputs.

Test in this order

  1. Do nothing when importer settings already match.
    First error, references and target environment
    First error, references and target environment
  2. Compare generated content and skip identical writes.
    First error, references and target environment
    First error, references and target environment
  3. Modify the source once, then verify that processing settles without further input.
    First error, references and target environment
    First error, references and target environment

Interpret the result

Stable inputs/settings should converge to unchanged output. Timestamps in generated files or repeated global reimports can prevent convergence. Verify after restarting too.

Related explanations

References