UXML and USS paths not available in AssetModificationProcessor.OnWillSaveAssets

When saving a UXML or USS file from within the UI Builder, the AssetModificationProcessor.OnWillSaveAssets callback is fired, but with an empty paths array.

Unity Version: 2019.3.15f1
UI Builder Version: 1.0.0-preview6

Sample Code to reproduce:

public class UxmlTest : UnityEditor.AssetModificationProcessor
{
    static string[] OnWillSaveAssets(string[] paths)
    {
        Debug.Log("Saving:  " + string.Join(",", paths));
    }
}

Log Output:

Saving:
UnityEngine.Debug:Log(Object)
UxmlTest:OnWillSaveAssets(String[ ]) (at Assets/UI/Editor/UxmlTest.cs:11)
UnityEditor.EditorApplication:Internal_CallGlobalEventHandler()

Hi,

I am quite curious regarding what are you trying to achieve. Can you share a bit more?

From my understanding, it seems like it should. Can you file a bug for this?

I am parsing changed uxml files upon save, then doing codegen based on elements within those files (to reduce my boilerplate). Happy to share the whole script, it’s not that big (yet).

Sorry for my ignorance; but can you link me to instructions to file a bug? I thought this forum was the way to do that :slight_smile:

6421950–717783–UxmlConstantCodegen.cs.txt (3.12 KB)

The forum is quicker to get pointers, workaround and event sometime find the solution to the problem you have in other threads. It is always a good place to start. For example, you could learn in the forum that we will simply never allow a specific usage and that is by design, so reporting a bug would be waiting a long time for having an answer that won’t really help you.

When you file a bug, the process is obviously longer, but also more rigorous, as it end up with a change in Unity. This guarantee that the issue will not be forgotten, that it will be properly tested and also we will look if we need to fix the bug in previous versions of unity for example.

When you file a bug, the more info you can provide the better! Usually, it will be looked upon by someone that has just the information of the bug report to confirm if it can be reproduced.

Try using the AssetPostprocessor instead, with an override of OnPostprocessAllAssets() which seems to work better with UI Builder saves.