AssetModificationProcessor.OnWillSaveAssets not running when saving certain UI Toolkit files.

Issue that is happening:
Unity is not running the Asset Moddification hooks like OnWillSaveAssets for USS files when they are edited.

Unity Versions checked:
Unity 2023.2 f20
Unity 6 preview f1

When did OnWillSaveAssets run properly:

  1. When creating a new USS file and confirming it’s name it does run on specifically on the meta file for the USS file created.

Steps to reproduce:
To test you can go to Unity’s API page for OnWillSaveAssets and even use their default example code snippet.
After creating the example script create a new USS file. See how the meta file activates it when a new USS file is created, but when editing the USS file in a code IDE, then saving the USS file it doesn’t run the OnWillSaveAssets hook.

The reason I find this as a bug is because things like Perforce use this hook, but can still see the file being committed to a stream on Helix Core Desktop.

Notes:
This could be intentional because some types of UI Toolkit Kit files don’t go through the serialization process all the time like other types of assets that inherit from the Object class.

Even though Style Sheets are scriptable objects they only hold the data from the USS files, but the USS files themselves might not be actual serialized assets. So there is a chance things like USS files are not meant to be able to run the OnWillSaveAssets making this just an edge case and not a bug.

HI,
Could you please submit this as a bug report?

Going to make a couple different projects in different versions of Unity to upload to the bug report real quick.

This was originally part of a custom Unity Package I was working on. Not sure if there is a way to upload custom packages or link public GitHub repos to Unity’s bug report system that is a repo of a custom package.

Also testing out if it changes based on the script being in a packages folder with assemblies and if the USS file being in the package folder or in the asset folder makes a difference.

I started to wonder if having a custom AssetPostProcessor script might be interfering with the AssetModificationProcessor calls.

1 Like

Tried to file bug reports through Unity’s bug report system in editor, but it would reach 100% on the file upload, close the progress bar, than freeze the bug reporter into an endless cycle of nothing happening from there till the bug reported just crashed.

Did it on minimum project repos to lower the file size, but even with a low file size it still crashed? Will have to try later to report the bug if I can get it working.

Yes there’s a limit. You can submit a smaller project and include a link to an external file such as Google drive.

It seems it was just a app crash on the bug reporter. Apparently it still got the bug report through before fully crashing.

CASE IN-75583 for the case ID.

1 Like