Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Editor scripting: execution order?

Discussion in 'Editor & General Support' started by Yandalf, Dec 9, 2019.

  1. Yandalf

    Yandalf

    Joined:
    Feb 11, 2014
    Posts:
    491
    Hey everyone!

    I'm making a few modular AssetPostprocessors for my project that are responsible for checking when new assets of certain types are made and then execute something (fill in an ID, create an additional file, etc etc).
    However, one Postprocessor is dependant on the applicable Postprocessors having executed first.
    Example: I create a new ScriptableObject that needs an ID value to be generated and stored within. This is handled by the SO-type's Postprocessor A.
    Then I want to run a second Postprocessor B that scans the entire project for assets of this type and stores their IDs in a list. This list is used within other editor scripts for referencing from a dropdown.
    If I can't ensure that A runs before B, this system simply won't work.
    Unfortunately, Unity's Script Execution Order settings seem to only work for runtime scripts, editor scripts simply aren't allowed in there. Besides, nothing in the documentation confirms these execution order rules are enforced in editor time.
    Anyone know a solution to this?