Unity upgrade breaks UXMLs

Hi, I have multiple UXMLs created a while back, plus some created in 2021.2.4f1 (where everything works).

After upgrading editor to 2022.1.0a16, the asset import fails on many of them. Does not seem to matter which previous version they were created in.

ArgumentNullException: Value cannot be null.
Parameter name: key

Some UXMLs lose their icon and association with UI Builder (they open in IDE). Others retain the link but the builder fails to open them: UI Builder - Unable to parse UXML file.

Console details

UI Builder Failed to open Assets/Content/UIDocuments/ModPanelContainer.uxml.uxml asset. This may be due to invalid UXML syntax or UXML syntax the UI Builder does not yet support. Check console for details.
UnityEngine.Debug:LogError (object)
Unity.UI.Builder.BuilderAssetUtilities:ValidateAsset (UnityEngine.UIElements.VisualTreeAsset,string) (at /Users/bokken/buildslave/unity/build/External/MirroredPackageSources/com.unity.ui.builder/Editor/Builder/Utilities/BuilderAssetUtilities.cs:77)
Unity.UI.Builder.BuilderToolbar:LoadDocument (UnityEngine.UIElements.VisualTreeAsset,bool,bool,string) (at /Users/bokken/buildslave/unity/build/External/MirroredPackageSources/com.unity.ui.builder/Editor/Builder/Toolbar/BuilderToolbar.cs:385)
Unity.UI.Builder.Builder:LoadDocument (UnityEngine.UIElements.VisualTreeAsset,bool) (at /Users/bokken/buildslave/unity/build/External/MirroredPackageSources/com.unity.ui.builder/Editor/Builder/Builder.cs:210)
Unity.UI.Builder.Builder:OnOpenAsset (int,int) (at /Users/bokken/buildslave/unity/build/External/MirroredPackageSources/com.unity.ui.builder/Editor/Builder/Builder.cs:287)
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&) (at /Users/bokken/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:189)

Note on the double “.uxml” extension in console reference: The file on drive is just single .uxml

Thank you for any ideas!

Hi @Kazko , a fix for this issue will land in the next 2022.1 release (0b1).

Thanks!

Thanks, that’s great news!

Running 2022.2.8f1 and it still seems to be an issue. The solution for me was to remove <Style> references to missing assets.

We seem to be having this too. All GUIDs match existing USS files any nested UXMLs too, no files are missing.
Trying @razamgar 's solution to no avail.

If we’re creating local packages or over VC as soon as we try to import the UI into another project it fails with the same error as the OP.

We can’t pass our own QA testing because of this.

I have a temporary solution by a python script:

# author: bbbirder
'''
What's this?

Run me before switch UnityEditor version between 2022.3 and 2021.2

'''

import os
import argparse

global s_find,s_replace

s_find = '''
importerOverride:
  nativeImporterType: 2089858483
  scriptedImporterType:
    serializedVersion: 2
    Hash: bd571fe0ab5ba4a563cd240b610bc57e
'''
s_replace = '''
importerOverride: UIRuntime::UxmlImporter
'''
def walk_meta_file(filepath):
    content = None
    with open(filepath,"r") as f:
        content = f.read(-1)
        if content.find(s_find) == ~0: return
    content = content.replace(s_find,s_replace)
    with open(filepath,"w",newline="\n") as f:
        f.write(content)
    print(filepath)

parser = argparse.ArgumentParser(description="VisualTreeAsset Converter")
parser.add_argument("mode",choices=["upgrade","downgrade"],help="Convert Mode")
parser.add_argument("-d","--dir",default=".",type=str)
args = parser.parse_args()

if args.mode == "upgrade":
    s_find,s_replace = s_replace,s_find

print("convert mode: ",args.mode)
print("convert dir: ",args.dir)

for root,dirs,files in os.walk(args.dir):
    for filename in files:
        filepath = os.path.join(root,filename)
        if(filepath.endswith(".uxml.meta")):
            walk_meta_file(filepath)

under the directory contains UXMLs, run the shell:

python .\convert_uidocuments.py upgrade # to newer version

or

python .\convert_uidocuments.py downgrade # to old version

It’s an old Post, but try updating your ‘noNamespaceSchemaLocation’ and Style ‘src’ values in your uxml files.

I just migrated my files over to the latest Unity version and the paths(I’m guessing the file id’s as well maybe?) changed, breaking the uxml validity.

Making a new UI Document and copying out the paths from the new file over to the old ones, as well as updating my custom style sheet location fixed my issues.