Search Unity

Feature Request Reload EditorWindow when associated UXML has changed ?

Discussion in 'UI Toolkit' started by aybeone, Jan 2, 2019.

  1. aybeone

    aybeone

    Joined:
    May 24, 2015
    Posts:
    107
    Currently, when using UXML I need to do the following to see changes made to the UXML file:
    • edit and save UXML
    • close and open the window to see the changes
    Can't Unity spot UXML has changed and reload the window ?

    (the tree is loaded in OnEnable)
     
  2. uDamian

    uDamian

    Unity Technologies

    Joined:
    Dec 11, 2017
    Posts:
    1,231
    This is a regression. We should have a fix soon. UXML (and USS) reloading should/will work.
     
  3. aybeone

    aybeone

    Joined:
    May 24, 2015
    Posts:
    107
    Great :)
     
  4. BusStopStudios

    BusStopStudios

    Joined:
    Mar 28, 2015
    Posts:
    22
    Do we have an update on this?
     
  5. Tom-Atom

    Tom-Atom

    Joined:
    Jun 29, 2014
    Posts:
    153
    Hi, I am solving it like this: add new menu item into upper-right menu dropdown like this (you have to implement IHasCustomMenu for your editor window):

    Code (CSharp):
    1.     public void AddItemsToMenu(GenericMenu menu) {
    2.         menu.AddItem(new GUIContent("Refresh"), false, RefreshEditorLayout);
    3.     }
    Then implement your RefreshEditorLayout method. In mine, I am rebuilding visual tree.
    When you edit UXML, you can then click Refresh menu item and it will refresh your editor window. It is not as parfect as it would if Unity detected changes itself, but it is much better than closing and openning editor window.

    RefreshInMenu.png
     
  6. BusStopStudios

    BusStopStudios

    Joined:
    Mar 28, 2015
    Posts:
    22
    I did this, it works for now, so after I make changes I just hit F9

    Code (CSharp):
    1.     static CustomWindow _window = null;
    2.  
    3.     [MenuItem("Window/Custom Editor")]
    4.     [Shortcut("Refresh Window",  KeyCode.F9)]
    5.     public static void ShowWindow()
    6.     {
    7.         if (_window) _window.Close();
    8.  
    9.         _window = GetWindow<CustomWindow>();
    10.         _window.titleContent = new GUIContent("CustomWindow");
    11.     }
     
  7. brunordeangelis

    brunordeangelis

    Joined:
    Jul 30, 2020
    Posts:
    4
    I reckon this hasn't been fixed yet, am I right? Saving changes to .uxml file does not auto reload the editor window. So far @BusStopStudios solution works well, but I was hoping to get native functionality.

    Thanks
     
  8. HugoBD-Unity

    HugoBD-Unity

    Unity Technologies

    Joined:
    May 14, 2018
    Posts:
    499
    Hi @brunordeangelis!

    Hot reload of EditorWindows when .uxml and .uss change should be working. Which version of Unity are you using?
     
  9. pajamajama

    pajamajama

    Joined:
    Oct 22, 2012
    Posts:
    66
    @hugobd
    doesn't seem to be working in 2019.4.9f1
     
  10. JuliaP_Unity

    JuliaP_Unity

    Unity Technologies

    Joined:
    Mar 26, 2020
    Posts:
    700
    Live Reload of Editor Windows only work for 2020.2, unfortunately.
    You can turn it on through the menu on the upper right side, look for "Live Reload" at the end of the list, just above the "UI Toolkit Debugger".

    Editing to add that if you save the files to disk, it should be working on 2019 and 2020.1.
     
  11. Grahammmm

    Grahammmm

    Joined:
    Jun 4, 2013
    Posts:
    12
    Could you be more specific on where to find this setting? I don't see it in 2020.1 and my windows are not refreshing even with a save. Thanks.
     
  12. JuliaP_Unity

    JuliaP_Unity

    Unity Technologies

    Joined:
    Mar 26, 2020
    Posts:
    700
    This setting is only available with Unity 2020.2 using the UI Toolkit package, so you won't see it on 2020.1 indeed.

    I just ran a quick test here with Unity 2020.1.6f1, saving UXML and USS file modifications caused my editor window to reload and show the new values. What version of Unity are you on, specifically? And is there anything particular about your editor window that pops to your mind and could interfere with this? If you can share some examples we can take a look, but I would suggest trying out a simple example (like creating an editor window through Create > UI Toolkit > Editor Window on your Project View) which is what I just tested here and works, and see if anything you added could have created an issue.
     
  13. Grahammmm

    Grahammmm

    Joined:
    Jun 4, 2013
    Posts:
    12
    Thanks for helping me out with this. I created a new project in 2020.1.6f1 and used the Editor Window option you suggested. With the window open, I added a label and changed the color of another one. I seem to be all saved up. Here is the result.
     

    Attached Files: