Thank you for responding @uMathieu and apologies for a necro-bump. I’ve plastered this entire code sample with align-self: flex-start;
, but no luck - the orange (well, orange-ish) container is wider than its children. Did I miss something?
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../../../UIElementsSchema/UIElements.xsd" editor-extension-mode="False">
<ui:VisualElement name="FixedWidthParent" style="background-color: rgba(0, 0, 0, 0); width: 470px; align-self: flex-start; align-items: flex-start;">
<ui:VisualElement name="Root" style="background-color: rgb(180, 135, 16); flex-direction: row; flex-wrap: wrap; align-self: flex-start; align-items: flex-start;">
<ui:VisualElement name="Entry" style="background-color: rgb(197, 55, 55); width: 64px; height: 64px; border-left-color: rgb(32, 136, 231); border-right-color: rgb(32, 136, 231); border-top-color: rgb(32, 136, 231); border-bottom-color: rgb(32, 136, 231); border-right-width: 2px; border-left-width: 2px; border-top-width: 2px; border-bottom-width: 2px; align-self: flex-start;" />
<ui:VisualElement name="Entry" style="background-color: rgb(197, 55, 55); width: 64px; height: 64px; border-left-color: rgb(32, 136, 231); border-right-color: rgb(32, 136, 231); border-top-color: rgb(32, 136, 231); border-bottom-color: rgb(32, 136, 231); border-right-width: 2px; border-left-width: 2px; border-top-width: 2px; border-bottom-width: 2px; align-self: flex-start;" />
<ui:VisualElement name="Entry" style="background-color: rgb(197, 55, 55); width: 64px; height: 64px; border-left-color: rgb(32, 136, 231); border-right-color: rgb(32, 136, 231); border-top-color: rgb(32, 136, 231); border-bottom-color: rgb(32, 136, 231); border-right-width: 2px; border-left-width: 2px; border-top-width: 2px; border-bottom-width: 2px; align-self: flex-start;" />
<ui:VisualElement name="Entry" style="background-color: rgb(197, 55, 55); width: 64px; height: 64px; border-left-color: rgb(32, 136, 231); border-right-color: rgb(32, 136, 231); border-top-color: rgb(32, 136, 231); border-bottom-color: rgb(32, 136, 231); border-right-width: 2px; border-left-width: 2px; border-top-width: 2px; border-bottom-width: 2px; align-self: flex-start;" />
<ui:VisualElement name="Entry" style="background-color: rgb(197, 55, 55); width: 64px; height: 64px; border-left-color: rgb(32, 136, 231); border-right-color: rgb(32, 136, 231); border-top-color: rgb(32, 136, 231); border-bottom-color: rgb(32, 136, 231); border-right-width: 2px; border-left-width: 2px; border-top-width: 2px; border-bottom-width: 2px; align-self: flex-start;" />
<ui:VisualElement name="Entry" style="background-color: rgb(197, 55, 55); width: 64px; height: 64px; border-left-color: rgb(32, 136, 231); border-right-color: rgb(32, 136, 231); border-top-color: rgb(32, 136, 231); border-bottom-color: rgb(32, 136, 231); border-right-width: 2px; border-left-width: 2px; border-top-width: 2px; border-bottom-width: 2px; align-self: flex-start;" />
<ui:VisualElement name="Entry" style="background-color: rgb(197, 55, 55); width: 64px; height: 64px; border-left-color: rgb(32, 136, 231); border-right-color: rgb(32, 136, 231); border-top-color: rgb(32, 136, 231); border-bottom-color: rgb(32, 136, 231); border-right-width: 2px; border-left-width: 2px; border-top-width: 2px; border-bottom-width: 2px; align-self: flex-start;" />
<ui:VisualElement name="Entry" style="background-color: rgb(197, 55, 55); width: 64px; height: 64px; border-left-color: rgb(32, 136, 231); border-right-color: rgb(32, 136, 231); border-top-color: rgb(32, 136, 231); border-bottom-color: rgb(32, 136, 231); border-right-width: 2px; border-left-width: 2px; border-top-width: 2px; border-bottom-width: 2px; align-self: flex-start;" />
</ui:VisualElement>
</ui:VisualElement>
</ui:UXML>
I feel like I’m going to have to use GeometryChangedEvent, but I’m hoping I just misunderstood something.
ChatGPT suggested I use width: fit-content;
. Little did it know that it is not a thing in USS - got a Trying to read value of type Dimension while reading a value of type Enum
error when manually specifying in UXML.