Skip to content
Widget

界面 / Widget

Widget Class

控件的基类


可挂载叶子节点的根节点,以及提供各种自动布局功能。

放置控件需要的通用属性与方法。

Hierarchy

Table of contents

Accessors

autoSizeHorizontalEnable(): boolean client
获取是否自动水平设置大小
autoSizeVerticalEnable(): boolean client
获取是否自动垂直设置大小
cachedGeometry(): Geometry client
获取上一次的GetTickSpaceGeometry
constraints(): Readonly<UIConstraintAnchors> client
获取控件的布局
desiredSize(): Vector2 client
获取期望大小
enable(): boolean client
是否可用
guid(): string client
获取控件GUID
isHovered(): boolean client
是否是hovered
mouseCursor(): MouseCursor client
获取控件上光标类型
name(): string client
获取名字
onFocusChange(): Delegate<(absolutionPosition: Vector2) => boolean> client
焦点改变事件
onFoucsLost(): Delegate<(absolutionPosition: Vector2) => boolean> client
丢失焦点事件
onKeyDownEvent(): Delegate<(absolutionPosition: Vector2, keyEvent: KeyEvent) => boolean> client
按键按下事件
onKeyUpEvent(): Delegate<(absolutionPosition: Vector2, keyEvent: KeyEvent) => boolean> client
按键抬起事件
onMouseButtonDoubleClick(): Delegate<(absolutionPosition: Vector2, pointEvent: PointerEvent) => boolean> client
鼠标双击事件
onMouseButtonDown(): Delegate<(absolutionPosition: Vector2, pointEvent: PointerEvent) => boolean> client
鼠标按下事件
onMouseButtonUp(): Delegate<(absolutionPosition: Vector2, pointEvent: PointerEvent) => boolean> client
鼠标抬起事件
onMouseEnter(): Delegate<(absolutionPosition: Vector2, pointEvent: PointerEvent) => boolean> client
鼠标进入控件事件
onMouseLeave(): Delegate<(absolutionPosition: Vector2, pointEvent: PointerEvent) => boolean> client
鼠标离开控件事件
onMouseMove(): Delegate<(absolutionPosition: Vector2, pointEvent: PointerEvent) => boolean> client
鼠标移动事件
onMouseWheel(): Delegate<(absolutionPosition: Vector2, pointEvent: PointerEvent) => boolean> client
鼠标滚轮滚动事件
onTouchEnded(): Delegate<(absolutionPosition: Vector2, pointEvent: PointerEvent) => boolean> client
触摸结束事件
onTouchMoved(): Delegate<(absolutionPosition: Vector2, pointEvent: PointerEvent) => boolean> client
触摸移动事件
onTouchStarted(): Delegate<(absolutionPosition: Vector2, pointEvent: PointerEvent) => boolean> client
触摸按下事件
paintSpaceGeometry(): Geometry client
获取最后一次用于渲染Widget的几何信息
parent(): Widget client
获取父节点
position(): Readonly<Vector2> client
获取控件的位置
renderOpacity(): number client
获取渲染透明度
renderScale(): Vector2 client
获取渲染缩放
renderShear(): Vector2 client
获取渲染错切形变
renderTransformAngle(): number client
获取渲染的角度
renderTransformPivot(): Vector2 client
获取渲染锚点
size(): Vector2 client
获取大小
tickSpaceGeometry(): Geometry client
获取最后一次用于驱动Widget Tick的几何信息
transform(): Readonly<UITransform> client
得到控件的大小和位置
visibility(): SlateVisibility client
获取可见性
visible(): boolean client
是否可见
zOrder(): number client
获取zorder

Methods

addChild(child: Widget): void client
添加子节点
destroyObject(): void client
立刻移除并销毁 不可以在使用
equal(that: Widget): boolean client
判断是不是同一个对象
findChildByPath(inPath: string): Widget client
通过相对路径查找节点
getChildAt(index: number): Widget client
获取第几位子节点
getChildByName<T: extends Widget<T>>(name: string): T: extends Widget<T> client
通过名字查找节点
getChildrenCount(): number client
获取子节点数量
invalidateLayoutAndVolatility(): void client
立刻触发重新渲染的和排布计算
removeAllChildren(): void client
清除所有子节点,会销毁UI无法再使用
removeChild(child: Widget): void client
移除节点,会销毁UI无法在使用
removeChildAt(index: number): void client
移除第几个节点,会销毁UI无法再使用
removeObject(): void client
立刻移除并添加到根节点 可以再使用

Accessors


autoSizeHorizontalEnable

get autoSizeHorizontalEnable(): boolean client

set autoSizeHorizontalEnable(bEnabled): void client

获取是否自动水平设置大小

Returns

boolean是否自动水平设置大小

获取是否自动水平设置大小

Parameters

bEnabledboolean

是否自动水平设置大小


autoSizeVerticalEnable

get autoSizeVerticalEnable(): boolean client

set autoSizeVerticalEnable(bEnabled): void client

获取是否自动垂直设置大小

Returns

boolean是否自动垂直设置大小

获取是否自动垂直设置大小

Parameters

bEnabledboolean

是否自动垂直设置大小


cachedGeometry

get cachedGeometry(): Geometry client

获取上一次的GetTickSpaceGeometry

Returns

Geometry返回上一次的 GetTickSpaceGeometry

constraints

get constraints(): Readonly<UIConstraintAnchors> client

set constraints(ininconstraints): void client

获取控件的布局

Returns

Readonly<UIConstraintAnchors>控件的布局

设置控件的布局

Parameters

ininconstraints UIConstraintAnchors控件的布局

desiredSize

get desiredSize(): Vector2 client

获取期望大小

Returns

Vector2返回期望大小

enable

get enable(): boolean client

set enable(isEnable): void client

是否可用

Returns

booleanboolean

设置可用性

Parameters

isEnable boolean可用性boolean

返回设置结果


guid

get guid(): string client

获取控件GUID

Returns

string控件GUID

isHovered

get isHovered(): boolean client

是否是hovered

Returns

booleanboolean

mouseCursor

get mouseCursor(): MouseCursor client

set mouseCursor(type): void client

获取控件上光标类型

Returns

MouseCursor光标类型

将光标类型设置到控件上

Parameters

typeMouseCursor

name

get name(): string client

set name(name): void client

获取名字

Returns

string返回名字

设定名字

Parameters

name string名字

onFocusChange

get onFocusChange(): Delegate<(absolutionPosition: Vector2) => boolean> client

焦点改变事件

Returns

Delegate<(absolutionPosition: Vector2) => boolean>

onFoucsLost

get onFoucsLost(): Delegate<(absolutionPosition: Vector2) => boolean> client

丢失焦点事件

Returns

Delegate<(absolutionPosition: Vector2) => boolean>

onKeyDownEvent

get onKeyDownEvent(): Delegate<(absolutionPosition: Vector2, keyEvent: KeyEvent) => boolean> client

按键按下事件

Returns

Delegate<(absolutionPosition: Vector2, keyEvent: KeyEvent) => boolean>

onKeyUpEvent

get onKeyUpEvent(): Delegate<(absolutionPosition: Vector2, keyEvent: KeyEvent) => boolean> client

按键抬起事件

Returns

Delegate<(absolutionPosition: Vector2, keyEvent: KeyEvent) => boolean>

onMouseButtonDoubleClick

get onMouseButtonDoubleClick(): Delegate<(absolutionPosition: Vector2, pointEvent: PointerEvent) => boolean> client

鼠标双击事件

Returns

Delegate<(absolutionPosition: Vector2, pointEvent: PointerEvent) => boolean>

onMouseButtonDown

get onMouseButtonDown(): Delegate<(absolutionPosition: Vector2, pointEvent: PointerEvent) => boolean> client

鼠标按下事件

Returns

Delegate<(absolutionPosition: Vector2, pointEvent: PointerEvent) => boolean>

onMouseButtonUp

get onMouseButtonUp(): Delegate<(absolutionPosition: Vector2, pointEvent: PointerEvent) => boolean> client

鼠标抬起事件

Returns

Delegate<(absolutionPosition: Vector2, pointEvent: PointerEvent) => boolean>

onMouseEnter

get onMouseEnter(): Delegate<(absolutionPosition: Vector2, pointEvent: PointerEvent) => boolean> client

鼠标进入控件事件

Returns

Delegate<(absolutionPosition: Vector2, pointEvent: PointerEvent) => boolean>

onMouseLeave

get onMouseLeave(): Delegate<(absolutionPosition: Vector2, pointEvent: PointerEvent) => boolean> client

鼠标离开控件事件

Returns

Delegate<(absolutionPosition: Vector2, pointEvent: PointerEvent) => boolean>

onMouseMove

get onMouseMove(): Delegate<(absolutionPosition: Vector2, pointEvent: PointerEvent) => boolean> client

鼠标移动事件

Returns

Delegate<(absolutionPosition: Vector2, pointEvent: PointerEvent) => boolean>

onMouseWheel

get onMouseWheel(): Delegate<(absolutionPosition: Vector2, pointEvent: PointerEvent) => boolean> client

鼠标滚轮滚动事件

Returns

Delegate<(absolutionPosition: Vector2, pointEvent: PointerEvent) => boolean>

onTouchEnded

get onTouchEnded(): Delegate<(absolutionPosition: Vector2, pointEvent: PointerEvent) => boolean> client

触摸结束事件

Returns

Delegate<(absolutionPosition: Vector2, pointEvent: PointerEvent) => boolean>

onTouchMoved

get onTouchMoved(): Delegate<(absolutionPosition: Vector2, pointEvent: PointerEvent) => boolean> client

触摸移动事件

Returns

Delegate<(absolutionPosition: Vector2, pointEvent: PointerEvent) => boolean>

onTouchStarted

get onTouchStarted(): Delegate<(absolutionPosition: Vector2, pointEvent: PointerEvent) => boolean> client

触摸按下事件

Returns

Delegate<(absolutionPosition: Vector2, pointEvent: PointerEvent) => boolean>

paintSpaceGeometry

get paintSpaceGeometry(): Geometry client

获取最后一次用于渲染Widget的几何信息

Returns

Geometry返回最后一次用于渲染Widget的几何信息

parent

get parent(): Widget client

获取父节点

Returns

Widget返回父节点

position

get position(): Readonly<Vector2> client

set position(inFigmaPosition): void client

获取控件的位置

Returns

Readonly<Vector2>控件的位置

设置控件的位置

Parameters

inFigmaPosition Vector2控件的位置

renderOpacity

get renderOpacity(): number client

set renderOpacity(InOpacity): void client

获取渲染透明度

Returns

number返回渲染透明度

设置渲染透明度 0 ~ 1

Parameters

InOpacity number透明度

renderScale

get renderScale(): Vector2 client

set renderScale(scale): void client

获取渲染缩放

Returns

Vector2返回渲染缩放

设置渲染缩放

Parameters

scale Vector2渲染缩放

renderShear

get renderShear(): Vector2 client

set renderShear(shear): void client

获取渲染错切形变

Returns

Vector2返回渲染错切形变

设置渲染错切形变

Parameters

shear Vector2渲染错切形变

renderTransformAngle

get renderTransformAngle(): number client

set renderTransformAngle(o): void client

获取渲染的角度

Returns

number返回渲染角度

设置渲染的角度

Parameters

o number渲染角度

renderTransformPivot

get renderTransformPivot(): Vector2 client

set renderTransformPivot(Pivot): void client

获取渲染锚点

Returns

Vector2返回渲染锚点

设置渲染锚点

Parameters

Pivot Vector2渲染锚点

size

get size(): Vector2 client

set size(inSize): void client

获取大小

Returns

Vector2FVector2D

设置控件的大小

Parameters

inSize Vector2输入大小

tickSpaceGeometry

get tickSpaceGeometry(): Geometry client

获取最后一次用于驱动Widget Tick的几何信息

Returns

Geometry返回最后一次用于驱动Widget Tick的几何信息

transform

get transform(): Readonly<UITransform> client

set transform(inTransform): void client

得到控件的大小和位置

Returns

Readonly<UITransform>控件的大小和位置

设置控件的大小和位置

Parameters

inTransform UITransform大小位置

visibility

get visibility(): SlateVisibility client

set visibility(Visibility): void client

获取可见性

Returns

SlateVisibility返回可见性

设置可见性

Parameters

Visibility SlateVisibility可见性

visible

get visible(): boolean client

是否可见

Returns

booleanboolean

zOrder

get zOrder(): number client

set zOrder(InZOrder): void client

获取zorder

Returns

numberzorder

设置zoder

Parameters

InZOrder number值越大在越上层

Methods

addChild

addChild(child): void client

添加子节点

Parameters

child Widget子控件

destroyObject

destroyObject(): void client

立刻移除并销毁 不可以在使用


equal

equal(that): boolean client

判断是不是同一个对象

Parameters

that Widget需要比较的另外一个对象

Returns

booleanboolean

findChildByPath

findChildByPath(inPath): Widget client

通过相对路径查找节点

Parameters

inPath string路径 range: 不限制

Returns

Widget返回查找节点结果

getChildAt

getChildAt(index): Widget client

获取第几位子节点

Parameters

index number下标 range: 大于 0 type: 整数

Returns

Widget找到的控件

getChildByName

getChildByName<T>(name): T client

通过名字查找节点

Parameters

name string名字
range: 不限制

Returns

T找到的控件

Type parameters

Textends Widget<T>

getChildrenCount

getChildrenCount(): number client

获取子节点数量

Returns

number子节点数量

invalidateLayoutAndVolatility

invalidateLayoutAndVolatility(): void client

立刻触发重新渲染的和排布计算


removeAllChildren

removeAllChildren(): void client

清除所有子节点,会销毁UI无法再使用


removeChild

removeChild(child): void client

移除节点,会销毁UI无法在使用

Parameters

child Widget需要移除的子控件

removeChildAt

removeChildAt(index): void client

移除第几个节点,会销毁UI无法再使用

Parameters

index number下标 range: 大于 0 type: 整数

removeObject

removeObject(): void client

立刻移除并添加到根节点 可以再使用