# Class ViewUtil

显示对象工具

#### Hierarchy

- ViewUtil

- Defined in assets/core/utils/ViewUtil.ts:11

#####
Index

### Constructors

constructor

### Methods

addNodeAnimation
calculateASpaceToBSpacePos
calculateScreenPosToSpacePos
createPrefabNode
createPrefabNodeAsync
findNodes
loadPrefabNode
nodeTreeInfoLite
uniformScale

## Constructors

### constructor

- new ViewUtil(): ViewUtil

- #### Returns ViewUtil

## Methods

### `Static` addNodeAnimation

- addNodeAnimation(path: string, node: Node, onlyOne?: boolean, isDefaultClip?: boolean): void

- 添加节点动画

  #### Parameters

  - ##### path: string

    资源路径

  - ##### node: Node

    目标节点

  - ##### onlyOne: boolean = true

    是否唯一

  - ##### isDefaultClip: boolean = false

    是否播放默认动画剪辑

  #### Returns void

  - Defined in assets/core/utils/ViewUtil.ts:142

### `Static` calculateASpaceToBSpacePos

- calculateASpaceToBSpacePos(a: Node, b: Node, aPos: Vec3): Vec3

- 节点之间坐标互转

  #### Parameters

  - ##### a: Node

    A节点

  - ##### b: Node

    B节点

  - ##### aPos: Vec3

    A节点空间中的相对位置

  #### Returns Vec3

  - Defined in assets/core/utils/ViewUtil.ts:56

### `Static` calculateScreenPosToSpacePos

- calculateScreenPosToSpacePos(event: EventTouch, space: Node): Vec3

- 屏幕转空间坐标

  #### Parameters

  - ##### event: EventTouch

    触摸事件

  - ##### space: Node

    转到此节点的坐标空间

  #### Returns Vec3

  - Defined in assets/core/utils/ViewUtil.ts:67

### `Static` createPrefabNode

- createPrefabNode(path: string): Node

- 从资源缓存中找到预制资源名并创建一个显示对象

  #### Parameters

  - ##### path: string

    资源路径

  #### Returns Node

  - Defined in assets/core/utils/ViewUtil.ts:94

### `Static` createPrefabNodeAsync

- createPrefabNodeAsync(path: string): Promise<Node>

- 加载预制并创建预制节点

  #### Parameters

  - ##### path: string

    资源路径

  #### Returns Promise<Node>

  - Defined in assets/core/utils/ViewUtil.ts:104

### `Static` findNodes

- findNodes(reg: RegExp, parent: Node, nodes?: Node[]): Node[]

- 正则搜索节点名字,符合条件的节点将会返回

  #### Parameters

  - ##### reg: RegExp

    正则表达式

  - ##### parent: Node

    要搜索的父节点

  - ##### `Optional` nodes: Node[]

    返回的数组（可选）

  #### Returns Node[]

  - Defined in assets/core/utils/ViewUtil.ts:37

### `Static` loadPrefabNode

- loadPrefabNode(path: string, callback: Function): void

- 加载预制节点

  #### Parameters

  - ##### path: string

    资源路径

  - ##### callback: Function

    资源加载完成回调

  #### Returns void

  - Defined in assets/core/utils/ViewUtil.ts:123

### `Static` nodeTreeInfoLite

- nodeTreeInfoLite(parent: Node, obj?: Map<string, Node>): null | Map<string, Node>

- 把Node当前的节点树结构根据Node命名转成一个js对象,重名的组件会覆盖， Node的name不应该包含空格键，否则将跳过

  #### Parameters

  - ##### parent: Node

    被遍历的Node组件

  - ##### `Optional` obj: Map<string, Node>

    绑定的js对象 (可选)

  #### Returns null | Map<string, Node>

  - Defined in assets/core/utils/ViewUtil.ts:18

### `Static` uniformScale

- uniformScale(targetWidth: number, targetHeight: number, defaultWidth: number, defaultHeight: number): Size

- 显示对象等比缩放

  #### Parameters

  - ##### targetWidth: number

    目标宽

  - ##### targetHeight: number

    目标高

  - ##### defaultWidth: number

    默认宽

  - ##### defaultHeight: number

    默认高

  #### Returns Size

  - Defined in assets/core/utils/ViewUtil.ts:81

Generated using TypeDoc