Trying to read value of type Dimension while reading a value of type Enum

Hi,
We are using Unity 2021.2.0b14 and Unity UI Builder / UI Toolkit.
We are creating some UI panels to use in editor mod (or sometimes runtime).

When we using VisualTree.CloneTree() function in some scripts, our program is giving error:

Trying to read value of type Dimension while reading a value of type Enum
UnityEngine.UIElements.VisualTreeAsset:CloneTree ()
ScenePanels.Types.PanelBase:Initialize () (at Assets/Scripts/ScenePanels/Types/PanelBase.cs:18)
ScenePanels.Instances.LaneletPanel:Initialize () (at Assets/Scripts/ScenePanels/Instances/LaneletPanel.cs:13)
Editor.EditorSceneOrganizer/<>c:b__2_0 (ScenePanels.Types.PanelBase) (at Assets/Scripts/ScenePanels/Editor/EditorSceneOrganizer.cs:37)
System.Collections.Generic.List1<ScenePanels.Types.PanelBase>:ForEach (System.Action1<ScenePanels.Types.PanelBase>)
Editor.EditorSceneOrganizer:InitializeAllPanels (UnityEditor.SceneView) (at Assets/Scripts/ScenePanels/Editor/EditorSceneOrganizer.cs:37)
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

We are adding some attachment in here and waiting your comments :slight_smile:

8424789–1115046–Attachments.zip (3.18 KB)

I think that’s a bug that was fixed in more recent Unity versions, can you try with 2021.3 (LTS)?

We tried with many Unity versions but result is same :frowning:

With 2021.3 (LTS) picture: Imgur: The magic of the Internet

I could find any obvious issues with the attachments you provided, but the Trying to read value of type Dimension while reading a value of type Enum error is usually caused by an error is the stylesheet. It seems to be trying to read a dimension, but got an unsupported enum value instead.

If you can’t spot it, I think the best thing to do would be to file an official bug report (Help > Report a Bug…).

1 Like

[SOLVED]
Hi,
We determined that the problem is caused by the regional format.
When we use width value “initial”, our uxml file writes “ınitial” and it broken the flow.
We changed our regional formats and checked uxml files than we changed the regional (turkısh for us) characters.

Old:
<uie:EnumField label="Render Option" type="ScenePanels.Enums.RenderType,Assembly-CSharp" value="Left" style="width: ınitial;" />

New:
<uie:EnumField label="Render Option" type="ScenePanels.Enums.RenderType,Assembly-CSharp" value="Left" style="width: initial;" />

Awesome, thanks for sharing.

1 Like

I still have this error at the moment and it appears once I opened my uxml file on Windows. I was working on MacOS. I have at least 10 documents but only one of them gives this significant error, and can’t figure out where it occurs.

Can you share that UXML? We’ll have a look.

Seems to load fine on my Windows machine, but I had to strip the templates/styles that aren’t included. It might make sense to file a bug report instead: Help > Report a Bug…

Alright I have sent a bug report. I will also try your scenerio on my Windows machine. Thanks