UI Builder opens up empty with an Exception: BadImageFormatException:

Unity 2021.18f1

Installed from com.unity.ui

BadImageFormatException: Expected reference type but got type kind 17
Unity.UI.Builder.BuilderInspectorLocalStyles..ctor (Unity.UI.Builder.BuilderInspector inspector, Unity.UI.Builder.BuilderInspectorStyleFields styleFields) (at <423884a9072a40feb1817ca34f260b36>:0)
Unity.UI.Builder.BuilderInspector..ctor (Unity.UI.Builder.BuilderPaneWindow paneWindow, Unity.UI.Builder.BuilderSelection selection, Unity.UI.Builder.HighlightOverlayPainter highlightOverlayPainter) (at <423884a9072a40feb1817ca34f260b36>:0)
Unity.UI.Builder.Builder.CreateUI () (at <423884a9072a40feb1817ca34f260b36>:0)
Unity.UI.Builder.BuilderPaneWindow.CreateUIInternal () (at <423884a9072a40feb1817ca34f260b36>:0)
Unity.UI.Builder.BuilderPaneWindow.OnEnable () (at <423884a9072a40feb1817ca34f260b36>:0)
Unity.UI.Builder.Builder.OnEnable () (at <423884a9072a40feb1817ca34f260b36>:0)
UnityEditor.EditorWindow:GetWindow()
Unity.UI.Builder.Builder:ShowWindow()

Edits: added stack trace

Hello! It’s not clear from your post whether you’re using packages or not, but if you’re using the com.unity.ui package we recommend you also install the UI Builder package (com.unity.ui.builder), even if there is already a UI Builder built into Unity 2021.1.

Let us know if this helps (or not!) :smile:

OK, so, it’s a bit confusing… at least for runtime UI development.

UI Builder is the tool used to build UI Toolki layouts, and it comes pre-installed w/ unity since 2021.
UI Toolkit is preview so I need to install it from a separate package feed and it (aparently) does not work with pre-installed UI Builder, so I need to install preview package of it as well - right?

Correct!

Partially correct. UI Toolkit is a core part of Unity for a while (2019), but Runtime support has been added last year by using the package that is preview. With Unity 2021.2+, UI Toolkit Runtime support is also part of the core product (and you don’t use the package with 2021.2+).

Although using the UI Toolkit package in 2021.1 with the built in UI Builder version may work, there may also be internal changes made after the Unity version was released and therefore we make sure to keep the UI Builder package updated to work with the UI Toolkit package at all times, therefore it’s recommended that if you’re using one of them from the package, you use both packages together.

Hope this clears it up! :sunglasses:

OK, installing UI Builder from com.unity.ui.builder solved the issue.

Thanks,
S.

This did not resolve the issue for me. I’m using Unity 2021.1.10f1. After ensuring both packages
I get the following error message:

Library\PackageCache\com.unity.ui.builder@1.0.0-preview.17\Editor\Builder\Utilities\BuilderAssetUtilities.cs(527,37): error CS0117: ‘FileUtil’ does not contain a definition for ‘WriteTextFileToDisk’

This version of Unity 2021.1 is too old so it’s not compatible with preview.15+. Ideally you’ll need Unity 2021.1.17f1.

Thanks. I can confirm that it works in the newer version of Unity.

Am getting the same error. Where can I find Unity UI Builder in Unity 2021.1.23f1? It’s not inside the “Unity Registry” Packages list :slight_smile:

I added

"com.unity.ui.builder": "1.0.0-preview.17",

into manifest.json and problem seems to be gone.

This fixed my issue. This was very confusing since UI Toolkit is built in recent Unity builds but doesn’t contain runtime support and so you have to get the preview package. And to get the preview package you have to import: com.unity.ui.builder

Anyhow I’m glad the issue is resolved.

@JuliaP_Unity , I ran into this now. I installed everything in the way that the documentation asked me to. Could you please add information to the documentation that we also have to install the builder package for it to be functional? Following the instructions and getting exceptions on startup isn’t the best experience.