I’ve been using the UIToolkit MinMaxSlider for some property drawers in 2022 LTS.
The code is really simple:
public override VisualElement CreatePropertyGUI(SerializedProperty property)
{
var attr = attribute as MinMaxAttribute;
// Create property container element.
var container = new VisualElement();
var slider = new MinMaxSlider(
attr.sliderMin, attr.sliderMax,
attr.sliderMin, attr.sliderMax);
var minField = new PropertyField(property);
slider.BindProperty(property);
container.Add(minField);
container.Add(slider);
return container;
}
The property is a Vector2 and attr.* values are plain floats.
In Unity 6 this continues to work, but starts to spam the console with the following error after i touch the slider:
Layout update is struggling to process current layout (consider simplifying to avoid recursive layout): EditorPanelRootElement unity-panel-container53 (x:0.00, y:0.00, width:634.00, height:1301.33) world rect: (x:0.00, y:0.00, width:634.00, height:1301.33)
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
The EditorPanelRootElement unity-panel-container53 is the Inspector window where I touched the slider.
I have the same issue. With a very basic style, the error starts spamming at some positions of the drag bar. When the errors start spamming, the FPS drops dramattically. Unity 6000.0.16f1
I did some research, and it seems the problem is in the MinMaxSlider implemenation. In UpdateDragElementPosition method, it uses dragMinThumb.resolvedStyle.width and dragMaxThumb.resolvedStyle.width to calculate dragger width and set thumbs positions. However, the widths are not round in my case. And at certain positions, the rounding error makes the width starting bouncing between two values. E.g. 130, 131, 130, 131, and so on indefinitely. Since the width gets set to a different value in every update, the element never gets its “IsDirty” value reset, and after 10 tries the updater gives up and logs the error.
The solution was to use the rounded values in this method:
var dragMinThumbWidth = Mathf.Round(dragMinThumb.resolvedStyle.width);
var dragMaxThumbWidth = Mathf.Round(dragMaxThumb.resolvedStyle.width);
I didn’t notice any impact to the visual behavior, but the error has gone. Hopefully, it will get fixed in some version of Unity. Till then, I’ll be using my local version of the control.
Hi, I struggle on the same issue.
How did you manage to override the Unity implementation with your own?
Being able to do that would be a blessing while investigating the newest features.Thanks for highlighting the issue, I spend half a day on this
well… i don’t think so… i’m using the 6000.3.2f1 (LTS) and i have the same problem : )
Layout update is struggling to process current layout (consider simplifying to avoid recursive layout): PanelRootElement PanelSettings (x:0.00, y:0.00, width:994.55, height:1171.86) world rect: (x:0.00, y:0.00, width:994.55, height:1171.86) UnityEngine.UIElements.UIElementsRuntimeUtilityNative:RepaintPanels (bool)