Class RectIntField
A field component for editing integer rectangle values with position (x,y) and size (width,height).
Implements
Inherited Members
Namespace: Unity.AppUI.UI
Assembly: Unity.AppUI.dll
Syntax
[UxmlElement]
public class RectIntField : BaseVisualElement, IEventHandler, IResolvedStyle, ITransform, ITransitionAnimations, IExperimentalFeatures, IVisualElementScheduler, IContextOverrideElement, IAdditionalDataHolder, IInputElement<RectInt>, IValidatableElement<RectInt>, ISizeableElement, INotifyValueChanging<RectInt>, INotifyValueChanged<RectInt>
Remarks
The RectIntField is a specialized input component that allows users to edit rectangle properties using integer values. It provides a convenient way to manipulate both position (X,Y) and size (Width,Height) of a rectangle in a single component.
The field is organized into two rows: Position and Size, each containing two numerical inputs. Position controls the X and Y coordinates, while Size controls the Width and Height values.
Tip: This component is particularly useful in scenarios where you need to edit rectangular bounds, layouts, or any other rectangle-based properties in your application.
The component supports validation through a callback function and can be styled using different size variants.
Examples
Basic usage with default values: Creating a basic RectIntField in UXML with initial values.
<RectIntField name="boundingBox" value="0,0,100,100" />
Advanced usage with validation and value change handling: Creating a RectIntField in code with validation and change handling.
var rectField = new RectIntField();
rectField.validateValue = (rect) => {
return rect.width >= 0 && rect.height >= 0 && rect.x >= 0 && rect.y >= 0;
};
rectField.RegisterValueChangedCallback(evt => {
Debug.Log($"Rectangle changed to: {evt.newValue}");
});
rectField.value = new RectInt(10, 10, 200, 100);
Using RectIntField in a layout editor: Using RectIntField as part of a UI layout editor with custom styling.
<RectIntField name="elementBounds" size="M" value="50,50,300,200">
<Style src="ElementEditor.uss" />
</RectIntField>
Constructors
RectIntField()
Default constructor.
Declaration
public RectIntField()
Fields
hFieldUssClassName
The RectIntField H NumericalField styling class.
Declaration
public const string hFieldUssClassName = "appui-rectfield__h-field"
Field Value
| Type | Description |
|---|---|
| string |
labelUssClassName
The RectIntField Label styling class.
Declaration
public const string labelUssClassName = "appui-rectfield__label"
Field Value
| Type | Description |
|---|---|
| string |
rowUssClassName
The RectIntField row styling class.
Declaration
public const string rowUssClassName = "appui-rectfield__row"
Field Value
| Type | Description |
|---|---|
| string |
sizeUssClassName
The RectIntField size styling class.
Declaration
public const string sizeUssClassName = "appui-rectfield--size-"
Field Value
| Type | Description |
|---|---|
| string |
ussClassName
The RectIntField main styling class.
Declaration
public const string ussClassName = "appui-rectfield"
Field Value
| Type | Description |
|---|---|
| string |
wFieldUssClassName
The RectIntField W NumericalField styling class.
Declaration
public const string wFieldUssClassName = "appui-rectfield__w-field"
Field Value
| Type | Description |
|---|---|
| string |
xFieldUssClassName
The RectIntField X NumericalField styling class.
Declaration
public const string xFieldUssClassName = "appui-rectfield__x-field"
Field Value
| Type | Description |
|---|---|
| string |
yFieldUssClassName
The RectIntField Y NumericalField styling class.
Declaration
public const string yFieldUssClassName = "appui-rectfield__y-field"
Field Value
| Type | Description |
|---|---|
| string |
Properties
contentContainer
The content container of the RectIntField.
Declaration
public override VisualElement contentContainer { get; }
Property Value
| Type | Description |
|---|---|
| VisualElement |
Overrides
invalid
The invalid state of the RectIntField.
Declaration
[CreateProperty]
[UxmlAttribute]
public bool invalid { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
size
The size of the RectIntField.
Declaration
[CreateProperty]
[UxmlAttribute]
public Size size { get; set; }
Property Value
| Type | Description |
|---|---|
| Size |
validateValue
The callback to validate the value of the RectIntField.
Declaration
[CreateProperty]
public Func<RectInt, bool> validateValue { get; set; }
Property Value
| Type | Description |
|---|---|
| Func<RectInt, bool> |
value
The value of the RectIntField.
Declaration
[CreateProperty]
[UxmlAttribute]
public RectInt value { get; set; }
Property Value
| Type | Description |
|---|---|
| RectInt |
Methods
GetSizeUssClassName(Size)
Declaration
public static string GetSizeUssClassName(Size enumValue)
Parameters
| Type | Name | Description |
|---|---|---|
| Size | enumValue |
Returns
| Type | Description |
|---|---|
| string |
SetValueWithoutNotify(RectInt)
Set the value of the RectIntField without notifying the change.
Declaration
public void SetValueWithoutNotify(RectInt newValue)
Parameters
| Type | Name | Description |
|---|---|---|
| RectInt | newValue | The new value of the RectIntField. |