Search Unity

  1. Click here to receive a gift with your purchase of Unity Pro or Unity Enterprise.
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

UXML and USS paths not available in AssetModificationProcessor.OnWillSaveAssets

Discussion in 'UI Toolkit' started by Rans, Oct 12, 2020.

  1. Rans

    Rans

    Joined:
    Oct 18, 2017
    Posts:
    2
    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:

    Code (CSharp):
    1. public class UxmlTest : UnityEditor.AssetModificationProcessor
    2. {
    3.     static string[] OnWillSaveAssets(string[] paths)
    4.     {
    5.         Debug.Log("Saving:  " + string.Join(",", paths));
    6.     }
    7. }
    8.  
    Log Output:

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

    SimonDufour

    Unity Technologies

    Joined:
    Jun 30, 2020
    Posts:
    43
    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?
     
    Last edited: Oct 14, 2020
  3. Rans

    Rans

    Joined:
    Oct 18, 2017
    Posts:
    2
    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 :)
     

    Attached Files:

  4. SimonDufour

    SimonDufour

    Unity Technologies

    Joined:
    Jun 30, 2020
    Posts:
    43
    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.
    https://support.unity3d.com/hc/en-us/articles/206336985-How-do-I-submit-a-bug-report-
     
  5. uDamian

    uDamian

    Unity Technologies

    Joined:
    Dec 11, 2017
    Posts:
    1,021
    Try using the AssetPostprocessor instead, with an override of OnPostprocessAllAssets() which seems to work better with UI Builder saves.
     
unityunity