Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Bug Template name cached

Discussion in 'UI Toolkit' started by pablobandinopla, Jul 9, 2023.

  1. pablobandinopla

    pablobandinopla

    Joined:
    Jul 2, 2021
    Posts:
    97
    I dont know if this is a bug...

    I was presented with a situation where i had to add namespaces and re-organize some files, and then the UIs stopped working throwing errors even tho i did all the appropiate renames.

    Scratching my head for a while, after everything looked alright but still getting errors, i saw the extra querystring piece that the IDE adds to the templates urls. File id, guid, etc... i had to delete that portion, then open the UI in the toolkit editor, and hit save, so those strings would regenerate...

    after that, it was working.
    Weird, i was expecting the UIToolkit system to have a watch process on the files and auto-detect changes on them... aparently it only happens when you save(?)

    So if anyone gets a weird error of empty or null Template Containers even tho everything is fine and the paths are ok, it probably means something is being cached (after the rename/replace)
     
  2. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    7,820
  3. pablobandinopla

    pablobandinopla

    Joined:
    Jul 2, 2021
    Posts:
    97
    Posted a bug report: https://unity3d.atlassian.net/servicedesk/customer/portal/2/IN-47050

    This is the report:

    1. What happened
    If you have a UIDocument that references a Template, while working in the UIToolkit window and hit save, a querystring will be appended to the src of the <ui:Template> with some data like fileID, etc... if you change the location of the template vía drag and drop into another folder (while in Visual Studio in my case) even if you change the src to the correct path in the uxml file using the template the UIToolkit system will reference the now broken old src. It is ignoring the value of the src attribute and looking into the querystring values instead.

    2. How can we reproduce it using the example you attached
    BugTest points to a template that doesn't exist, but the UIToolkit still finds the file because the url was changed by hand and the querystring still points to the old files. I did this to prove a point because in my original error, i moved the template files to another folder and changed by hand the reference (without deleting the querystring portion of the src) and i was getting error of template not found, once i deleted the querystring portion and opened and hit save again in the UIToolkit editor the problem was solved.

    3. Possible solution: If the template can't be found, it should re-check that the SRC file exists instead of only cheching the fileID query string attribute.​
     
    karl_jones likes this.