UI / Widget
Widget Class
Base class of widget
It can attach the root node of leaf node and provide various automatic layout functions.
Common property and methods required for placing widget.
Hierarchy
Widget
↳
Button
↳
Canvas
↳
Checkbox
↳
Dropdown
↳
FlipBook
↳
Image
↳
InputBox
↳
ListView
↳
Mask
↳
TouchPad
↳
TreeView
Table of contents
Properties
onCustomPropertyChange: Readonly <MulticastDelegate <(path : string , value : unknown , oldValue : unknown ) => void >> other |
---|
Monitor custom attribute synchronization events |
Accessors
alignPosition(): Readonly <Vector2 > other |
---|
Get the align position of the widget. When the align method is right align, bottom align, and center align, the value of alignPosition is different from that of position; |
autoSizeHorizontalEnable(): boolean other |
Get whether to automatically set the size horizontally |
autoSizeVerticalEnable(): boolean other |
Get whether to set the size automatically vertical |
cachedGeometry(): Geometry other |
Get the previous Get TickSpaceGeometry |
constraints(): Readonly <UIConstraintAnchors > other |
Get the layout of the control |
desiredSize(): Vector2 other |
Obtain expected size |
enable(): boolean other |
Is it available |
guid(): string other |
Get the widget GUID |
isHovered(): boolean other |
Is it hovered |
mouseCursor(): MouseCursor other |
Get the cursor type on the widget |
name(): string other |
Get Name |
paintSpaceGeometry(): Geometry other |
Get the last geometric information used to render the Widget |
parent(): Widget other |
Get parent node |
pivot(): Vector2 other |
Get the position of the widget anchor. This property determine the relative position of the widget graph and the anchor; At (0,0), the anchor point is located in the upper left corner of the control; (0.5,0.5), the anchor is at the center of the widget |
position(): Readonly <Vector2 > other |
Get the position of the control |
renderOpacity(): number other |
Obtain rendering transparency |
renderScale(): Vector2 other |
Get rendering scaling |
renderShear(): Vector2 other |
Obtain rendering misalignment deformation |
renderTransformAngle(): number other |
Obtain the rendering angle |
renderTransformPivot(): Vector2 other |
Get Render anchor |
size(): Vector2 other |
Get size |
tickSpaceGeometry(): Geometry other |
Retrieve the last geometric information used to drive Widget Tick |
transform(): Readonly <UITransform > other |
Obtain the size and position of the control |
visibility(): SlateVisibility other |
Get visibility |
visible(): boolean other |
Is it visible |
zOrder(): number other |
Get Zorder |
Methods
addChild(child : Widget ): void other |
---|
Add child nodes |
clone(position : Vector2 , Parent? : any ): Widget other |
Clone the UI widget and its child nodes to the specified parent widget position (default to its parent node) |
destroyObject(): void other |
Remove and destroy immediately. Cannot be used again |
equal(that : Widget ): boolean other |
Determine if it is the same object |
findChildByPath(inPath : string ): Widget other |
Find nodes by relative path |
getChildAt(index : number ): Widget other |
What is the position node to obtain |
getChildByName<T : extends Widget <T >>(name : string ): T : extends Widget <T > other |
Search for nodes by name |
getChildrenCount(): number other |
Obtain the number of child nodes |
getCustomProperties(): string [] other |
Get all customize property |
getCustomProperty<T : extends CustomPropertyType >(propertyName : string ): T : extends CustomPropertyType other |
Get customize property |
getCustomPropertyChangeDelegate(property ): Readonly <MulticastDelegate <(path : string , value : unknown , oldValue : unknown ) => void >> other |
Event proxy triggered when a given object property is modified |
invalidateLayoutAndVolatility(): void other |
Immediately trigger re rendering and layout calculation |
removeAllChildren(): void other |
Clearing all child nodes will destroy the UI and render it unusable |
removeChild(child : Widget ): void other |
Removing a node will destroy the UI and make it unusable |
removeChildAt(index : number ): void other |
Removing the third node will destroy the UI and render it unusable |
removeObject(): void other |
Immediately remove and add to the root node for reuse |
serialize(): string other |
Serialize UI widget |
setCustomProperty(propertyName : string , value : undefined CustomPropertyType ): void other |
Set custom attributes |
deserialize(Data : string , Parent? : Widget ): Widget other |
Deserialize UI |
Properties
onCustomPropertyChange
• onCustomPropertyChange: Readonly
<MulticastDelegate
<(path
: string
, value
: unknown
, oldValue
: unknown
) => void
>> other
Monitor custom attribute synchronization events
this.onCustomPropertyChange.add((path, value, oldValue) => {
Console. log (the ` property ${path} change, the new value is ${value}, the old value is ${oldValue} `);
});
this.onCustomPropertyChange.add((path, value, oldValue) => {
Console. log (the ` property ${path} change, the new value is ${value}, the old value is ${oldValue} `);
});
Accessors
alignPosition
• | • | ||||
---|---|---|---|---|---|
Get the align position of the widget. When the align method is right align, bottom align, and center align, the value of alignPosition is different from that of position; At this point, the coordinate systems used for calculating the two sets of positions are different. For example, when set to bottom right alignment, the alignPosition of the control is calculated based on the parent's bottom right corner as the origin Returns
| Set the align position of the widget. When the align mode is right align, bottom align, and center align, the value of alignPosition is different from that of position; At this point, the coordinate systems used for calculating the two sets of positions are different. For example, when set to bottom right alignment, the alignPosition of the control is calculated based on the parent's bottom right corner as the origin Parameters
|
autoSizeHorizontalEnable
• | • | ||||
---|---|---|---|---|---|
Get whether to automatically set the size horizontally Returns
| Get whether to automatically set the size horizontally Parameters
Is the size automatically set horizontally |
autoSizeVerticalEnable
• | • | ||||
---|---|---|---|---|---|
Get whether to set the size automatically vertical Returns
| Get whether to set the size automatically vertical Parameters
Whether to automatically set the size vertically |
cachedGeometry
• | ||
---|---|---|
Get the previous Get TickSpaceGeometry Returns
|
constraints
• | • | ||||
---|---|---|---|---|---|
Get the layout of the control Returns
| Set the layout of the widget Parameters
|
desiredSize
• | ||
---|---|---|
Obtain expected size Returns
|
enable
• | • | ||||
---|---|---|---|---|---|
Is it available Returns
| Set availability Parameters
Return the setting result |
guid
• | ||
---|---|---|
Get the widget GUID Returns
|
isHovered
• | ||
---|---|---|
Is it hovered Returns
|
mouseCursor
• | • | ||||
---|---|---|---|---|---|
Get the cursor type on the widget Returns
| Set cursor type to widget Parameters
|
name
• | • | ||||
---|---|---|---|---|---|
Get Name Returns
| Set name Parameters
|
paintSpaceGeometry
• | ||
---|---|---|
Get the last geometric information used to render the Widget Returns
|
parent
• | ||
---|---|---|
Get parent node Returns
|
pivot
• | • | ||||
---|---|---|---|---|---|
Get the position of the widget anchor. This property determine the relative position of the widget graph and the anchor; At (0,0), the anchor point is located in the upper left corner of the control; (0.5,0.5), the anchor is at the center of the widget The position of the anchor itself is determined by the position or alignPosition Returns
| Set the position of the widget anchor. This property determine the relative position of the widget graph and the anchor; (0,0), the anchor is located in the upper left corner of the widget; (0.5,0.5), the anchor is at the center of the widget; The position of the anchor itself is determined by the position or alignPosition Parameters
|
position
• | • | ||||
---|---|---|---|---|---|
Get the position of the control Returns
| Set the position of the control Parameters
|
renderOpacity
• | • | ||||
---|---|---|---|---|---|
Obtain rendering transparency Returns
| Set rendering transparency to 0~1 Parameters
|
renderScale
• | • | ||||
---|---|---|---|---|---|
Get rendering scaling Returns
| Set render scale Parameters
|
renderShear
• | • | ||||
---|---|---|---|---|---|
Obtain rendering misalignment deformation Returns
| Set rendering misalignment deformation Parameters
|
renderTransformAngle
• | • | ||||
---|---|---|---|---|---|
Obtain the rendering angle Returns
| Set the rendering angle Parameters
|
renderTransformPivot
• | • | ||||
---|---|---|---|---|---|
Get Render anchor Returns
| Set render anchor Parameters
|
size
• | • | ||||
---|---|---|---|---|---|
Get size Returns
| Set the size of the widget Parameters
|
tickSpaceGeometry
• | ||
---|---|---|
Retrieve the last geometric information used to drive Widget Tick Returns
|
transform
• | • | ||||
---|---|---|---|---|---|
Obtain the size and position of the control Returns
| Set the size and position of the control Parameters
|
visibility
• | • | ||||
---|---|---|---|---|---|
Get visibility Returns
| Set Visible Parameters
|
visible
• | ||
---|---|---|
Is it visible Returns
|
zOrder
• | • | ||||
---|---|---|---|---|---|
Get Zorder Returns
| Set Zoder Parameters
|
Methods
addChild
• addChild(child
): void
other
Add child nodes
Parameters
child Widget | Usage: Child Control |
---|
clone
• clone(position
, Parent?
): Widget
other
Clone the UI widget and its child nodes to the specified parent widget position (default to its parent node)
Parameters
position Vector2 | Position of generate widget after cloning |
---|---|
Parent? any | The cloned widget needs to be generate under this widget |
Returns
Widget | Clone generated UI controls |
---|
destroyObject
• destroyObject(): void
other
Remove and destroy immediately. Cannot be used again
equal
• equal(that
): boolean
other
Determine if it is the same object
Parameters
that Widget | Usage: Another object that needs to be compared |
---|
Returns
boolean | boolean |
---|
findChildByPath
• findChildByPath(inPath
): Widget
other
Find nodes by relative path
Parameters
inPath string | Usage: Path range: Unrestricted |
---|
Returns
Widget | Return the search node results |
---|
getChildAt
• getChildAt(index
): Widget
other
What is the position node to obtain
Parameters
index number | Usage: subscript range: greater than 0 type: integer |
---|
Returns
Widget | Widget found |
---|
getChildByName
• getChildByName<T
>(name
): T
other
Search for nodes by name
Parameters
name string | Usage: Name Range: Unrestricted |
---|
Returns
T | Widget found |
---|
Type parameters
T | extends Widget <T > |
---|
getChildrenCount
• getChildrenCount(): number
other
Obtain the number of child nodes
Returns
number | Number of child nodes |
---|
getCustomProperties
• getCustomProperties(): string
[] other
Get all customize property
Returns
string [] | Attribute Name List |
---|
const attributes = this.getAttributes();
console.log(attributes);
// ["name", "age"]
const attributes = this.getAttributes();
console.log(attributes);
// ["name", "age"]
getCustomProperty
• getCustomProperty<T
>(propertyName
): T
other
Get customize property
Parameters
propertyName string | Attribute Name |
---|
Returns
T | Property value |
---|
Type parameters
T | extends CustomPropertyType |
---|
getCustomPropertyChangeDelegate
• getCustomPropertyChangeDelegate(property
): Readonly
<MulticastDelegate
<(path
: string
, value
: unknown
, oldValue
: unknown
) => void
>> other
Event proxy triggered when a given object property is modified
Parameters
property string | Name of object property |
---|
Returns
Readonly <MulticastDelegate <(path : string , value : unknown , oldValue : unknown ) => void >> | Proxy Object |
---|
invalidateLayoutAndVolatility
• invalidateLayoutAndVolatility(): void
other
Immediately trigger re rendering and layout calculation
removeAllChildren
• removeAllChildren(): void
other
Clearing all child nodes will destroy the UI and render it unusable
removeChild
• removeChild(child
): void
other
Removing a node will destroy the UI and make it unusable
Parameters
child Widget | Usage: Child controls that need to be removed |
---|
removeChildAt
• removeChildAt(index
): void
other
Removing the third node will destroy the UI and render it unusable
Parameters
index number | Usage: subscript range: greater than 0 type: integer |
---|
removeObject
• removeObject(): void
other
Immediately remove and add to the root node for reuse
serialize
• serialize(): string
other
Serialize UI widget
Returns
string | Return the JSON string serialized by the incoming widget |
---|
setCustomProperty
• setCustomProperty(propertyName
, value
): void
other
Set custom attributes
Parameters
propertyName string | Attribute Name |
---|---|
value undefined CustomPropertyType | Property value |
deserialize
• Static
deserialize(Data
, Parent?
): Widget
other
Deserialize UI
Parameters
Data string | Usage: JSON string that needs to be deserialized |
---|---|
Parent? Widget | Usage: The parent node of the generated UI control |
Returns
Widget | Return the UI obtained after deserialization of the incoming JSON string |
---|