Search Issue Tracker

By Design

By Design in 2022.2.X

Votes

4

Found in

2020.3.33f1

2021.3.1f1

2022.1.0f1

2022.2.0a11

Issue ID

UUM-3475

Regression

Yes

[UI Toolkit] Input Fields created with "PropertyField" and "TextField" have different widths when changing the Inspector window

UI Toolkit Controls

-

How to reproduce:
1. Open project "BugReport.zip"
2. Open the "Scene" Scene (Assets > Scene)
3. In the Hierarchy window select the "MyComponent" GameObject
4. Keep changing the Inspector window width

Expected result: Both Input Fields are the same width
Actual result: Both Input Fields have different width

Reproducible with: 1.0.0-preview.17, 1.0.0-preview.18 (2020.3.33f1), 1.0.0 (2021.3.1f1, 2022.1.0f1, 2022.2.0a11)
Not reproducible with: 1.0.0-preview.16 (2020.3.33f1)
Could not test with: 2019.4.38f1 (No UI Toolkit package)

  1. Resolution Note:

    Adding the `alignedFieldUssClassName` class to the field element will enable the same alignment as a PropertyField.

    https://docs.unity3d.com/ScriptReference/UIElements.BaseField_1-alignedFieldUssClassName.html

    We will seek to improve the documentation to make this clearer.

  2. Resolution Note (2022.2.X):

    Adding the `alignedFieldUssClassName` class to the field element will enable the same alignment as a PropertyField.

    https://docs.unity3d.com/ScriptReference/UIElements.BaseField_1-alignedFieldUssClassName.html

    We will seek to improve the documentation to make this clearer.

Comments (2)

  1. karl_jones

    Sep 19, 2023 10:38

    The property field adds a class to its child elements, this class is what causes them to be aligned.
    For example:
    `field2.AddToClassList(BaseField<string>.alignedFieldUssClassName);`

    We will look into improving our documentation to make this more clear.

  2. Catsoft-Works

    Jun 24, 2022 10:06

    That makes no sense.

    PropertyFields create specific type fields (FloatField, TextField, etc...) as child UIToolkit elements. If creating a PropertyField, generates a FloatField that has a different width value than directly creating a FloatField, how can we expect to make consistent interfaces?

    So instead of fixing PropertyFields width, you propose we change ALL other specific fields and add the class .unity-base-field__aligned?

    I'd urge to review this ticket.

Add comment

Log in to post comment