资源管理器

### Hierarchy

- AssetsManager

## Index

### Constructors

- constructor

### Properties

- resCache
- resCacheProxy
- resLoaderType
- resPath

### Methods

- addLoader
- blobToImage
- cacheRes
- destroyAllRes
- destroyRes
- fileOrBlobToDataURL
- findAnimConfig
- getAllResUuids
- getLoader
- getRes
- getUUIDFromUrl
- loadAnim
- loadAny
- loadFont
- loadImage
- loadImageFromBlob
- loadJson
- loadJson5
- loadPrefab
- loadResItems
- loadSheet
- loadSheetDisperse
- loadTexture
- loadTextureFromBlob
- loadTxt
- resolveUrl
- setResCacheProxy
- setResPath

## Constructors

### constructor

- new AssetsManager(): AssetsManager

- - Defined in assets-manager/AssetsManager.ts:20

  #### Returns AssetsManager

## Properties

### Private resCache

resCache: object

- Defined in assets-manager/AssetsManager.ts:16

#### Type declaration

### Private resCacheProxy

resCacheProxy: any

- Defined in assets-manager/AssetsManager.ts:18

### Private resLoaderType

resLoaderType: any

- Defined in assets-manager/AssetsManager.ts:20

### Private resPath

resPath: string = ""

- Defined in assets-manager/AssetsManager.ts:17

## Methods

### addLoader

- addLoader(ext: string, loader: Function): void

- - Defined in assets-manager/AssetsManager.ts:54

  增加加载器

  #### Parameters

  - ##### ext: string

    需加载的文件后缀

  - ##### loader: Function

    加载方法，返回携带最终资源的Promise

  #### Returns void

### Private blobToImage

- blobToImage(blob: any): Promise<Object>

- - Defined in assets-manager/AssetsManager.ts:505

  #### Parameters

  - ##### blob: any

  #### Returns Promise<Object>

### Private cacheRes

- cacheRes(res: any, url: string, uuid?: string): void

- - Defined in assets-manager/AssetsManager.ts:175

  缓存资源

  #### Parameters

  - ##### res: any

  - ##### url: string

  - ##### Optional uuid: string

  #### Returns void

### destroyAllRes

- destroyAllRes(): any

- - Defined in assets-manager/AssetsManager.ts:136

  销毁全部资源

  #### Returns any

### destroyRes

- destroyRes(uuidOrUuids: string | Array<string>): void

- - Defined in assets-manager/AssetsManager.ts:123

  销毁资源

  #### Parameters

  - ##### uuidOrUuids: string | Array<string>

  #### Returns void

### Private fileOrBlobToDataURL

- fileOrBlobToDataURL(obj: any): Promise<string>

- - Defined in assets-manager/AssetsManager.ts:492

  #### Parameters

  - ##### obj: any

  #### Returns Promise<string>

### Private findAnimConfig

- findAnimConfig(animations: any, name: any): any

- - Defined in assets-manager/AssetsManager.ts:367

  #### Parameters

  - ##### animations: any

  - ##### name: any

  #### Returns any

### getAllResUuids

- getAllResUuids(): string[]

- - Defined in assets-manager/AssetsManager.ts:145

  获取所有uuid值

  #### Returns string[]

### getLoader

- getLoader(ext: string, url: string): function

- - Defined in assets-manager/AssetsManager.ts:44

  获取一个加载器

  #### Parameters

  - ##### ext: string

  - ##### url: string

  #### Returns function

  - - (url: string, uuid: string, cache: boolean, config: any): Promise<any>

    - #### Parameters

      - ##### url: string

      - ##### uuid: string

      - ##### cache: boolean

      - ##### config: any

      #### Returns Promise<any>

### getRes

- getRes(uuid: string): any

- - Defined in assets-manager/AssetsManager.ts:108

  获取资源

  #### Parameters

  - ##### uuid: string

  #### Returns any

### Private getUUIDFromUrl

- getUUIDFromUrl(url: any): string

- - Defined in assets-manager/AssetsManager.ts:165

  根据url推断名称，只是获取短文件名

  #### Parameters

  - ##### url: any

  #### Returns string

### loadAnim

- loadAnim(url: string, uuid?: string, cache?: boolean, config?: any): Promise< FrameAnimation []>

- - Defined in assets-manager/AssetsManager.ts:386

  加载帧动画资源(多个)

  #### Parameters

  - ##### url: string

    url

  - ##### Optional uuid: string

    唯一名

  - ##### Default value cache: boolean = true

    是否缓存

  - ##### Optional config: any

    资源配置

  #### Returns Promise< FrameAnimation []>

  Promise<any> 资源

### loadAny

- loadAny(url: string, uuid?: string, cache?: boolean, config?: any, options?: object, type?: string): Promise<any>

- - Defined in assets-manager/AssetsManager.ts:192

  加载任意网络资源

  #### Parameters

  - ##### url: string

    url

  - ##### Optional uuid: string

  - ##### Default value cache: boolean = true

    是否缓存

  - ##### Optional config: any

    资源配置

  - ##### Default value options: object = {}

    请求配置

  - ##### Default value type: string = "arraybuffer"

    类型(json|text|arraybuffer|blob)

  #### Returns Promise<any>

  Promise<any> 资源

### loadFont

- loadFont(url: string, uuid?: string, cache?: boolean, config?: any): Promise< Sheet >

- - Defined in assets-manager/AssetsManager.ts:355

  加载文图字资源

  #### Parameters

  - ##### url: string

    url

  - ##### Optional uuid: string

    唯一名

  - ##### Default value cache: boolean = true

    是否缓存

  - ##### Optional config: any

    资源配置

  #### Returns Promise< Sheet >

  Promise<any> 资源

### loadImage

- loadImage(url: string, uuid?: string, cache?: boolean, config?: any): Promise<HTMLImageElement>

- - Defined in assets-manager/AssetsManager.ts:425

  加载图片资源

  #### Parameters

  - ##### url: string

    url

  - ##### Optional uuid: string

    唯一名

  - ##### Default value cache: boolean = true

    是否缓存

  - ##### Optional config: any

    资源配置

  #### Returns Promise<HTMLImageElement>

### loadImageFromBlob

- loadImageFromBlob(url: string, uuid?: string, cache?: boolean, config?: any): Promise<any>

- - Defined in assets-manager/AssetsManager.ts:449

  加载blob图片资源

  #### Parameters

  - ##### url: string

    url

  - ##### Optional uuid: string

    唯一名

  - ##### Default value cache: boolean = true

    是否缓存

  - ##### Optional config: any

    资源配置

  #### Returns Promise<any>

  Promise<any> 资源

### loadJson

- loadJson(url: string, uuid?: string, cache?: boolean, config?: any): Promise<any>

- - Defined in assets-manager/AssetsManager.ts:242

  加载json资源

  #### Parameters

  - ##### url: string

    url

  - ##### Optional uuid: string

    唯一名

  - ##### Default value cache: boolean = true

    是否缓存

  - ##### Optional config: any

    资源配置

  #### Returns Promise<any>

  Promise<any> 资源

### loadJson5

- loadJson5(url: string, uuid?: string, cache?: boolean, config?: any): Promise<any>

- - Defined in assets-manager/AssetsManager.ts:262

  加载json5资源

  #### Parameters

  - ##### url: string

    url

  - ##### Optional uuid: string

    唯一名

  - ##### Default value cache: boolean = true

    是否缓存

  - ##### Optional config: any

    资源配置

  #### Returns Promise<any>

  Promise<any> 资源

### loadPrefab

- loadPrefab(url: any, uuid?: any, cache?: boolean, config?: any): Promise<any>

- - Defined in assets-manager/AssetsManager.ts:279

  加载预制资源

  #### Parameters

  - ##### url: any

    url

  - ##### Optional uuid: any

    唯一名

  - ##### Default value cache: boolean = true

    是否缓存

  - ##### Optional config: any

    资源配置

  #### Returns Promise<any>

  Promise<any> 资源

### loadResItems

- loadResItems(items: Array<any | string>, progress?: function): Promise<Array<any>>

- - Defined in assets-manager/AssetsManager.ts:72

  加载一批资源

  #### Parameters

  - ##### items: Array<any | string>

    资源数组: ['aaa.png', {uuid: 'bbb', url: 'alias.png'}]

  - ##### Optional progress: function

    进度回调，参数为加载百分比

    - - (percentage: number): void

      - #### Parameters

        - ##### percentage: number

        #### Returns void

  #### Returns Promise<Array<any>>

  Promise<Array<any>> 资源组

### loadSheet

- loadSheet(url: string, uuid?: string, cache?: boolean, config?: any): Promise< Sheet >

- - Defined in assets-manager/AssetsManager.ts:295

  加载图集资源

  #### Parameters

  - ##### url: string

    url

  - ##### Optional uuid: string

    唯一名

  - ##### Default value cache: boolean = true

    是否缓存

  - ##### Optional config: any

    资源配置

  #### Returns Promise< Sheet >

  Promise<any> 资源

### loadSheetDisperse

- loadSheetDisperse(url: string, uuid?: string, cache?: boolean, config?: any): Promise< Sheet >

- - Defined in assets-manager/AssetsManager.ts:338

  加载散列的图集

  #### Parameters

  - ##### url: string

    url

  - ##### Optional uuid: string

    唯一名

  - ##### Default value cache: boolean = true

    是否缓存

  - ##### Optional config: any

    资源配置

  #### Returns Promise< Sheet >

  Promise<any> 资源

### loadTexture

- loadTexture(url: string, uuid?: string, cache?: boolean, config?: any): Promise< Texture >

- - Defined in assets-manager/AssetsManager.ts:466

  加载纹理资源

  #### Parameters

  - ##### url: string

    url

  - ##### Optional uuid: string

    唯一名

  - ##### Default value cache: boolean = true

    是否缓存

  - ##### Optional config: any

    资源配置

  #### Returns Promise< Texture >

  Promise<any> 资源

### loadTextureFromBlob

- loadTextureFromBlob(url: string, uuid?: string, cache?: boolean, config?: any): Promise< Texture >

- - Defined in assets-manager/AssetsManager.ts:483

  加载blob纹理资源

  #### Parameters

  - ##### url: string

    url

  - ##### Optional uuid: string

    唯一名

  - ##### Default value cache: boolean = true

    是否缓存

  - ##### Optional config: any

    资源配置

  #### Returns Promise< Texture >

  Promise<any> 资源

### loadTxt

- loadTxt(url: string, uuid?: string, cache?: boolean, config?: any): Promise<string>

- - Defined in assets-manager/AssetsManager.ts:222

  加载文本资源

  #### Parameters

  - ##### url: string

    url

  - ##### Optional uuid: string

    唯一名

  - ##### Default value cache: boolean = true

    是否缓存

  - ##### Optional config: any

    资源配置

  #### Returns Promise<string>

  Promise<any> 资源

### Private resolveUrl

- resolveUrl(url: string): string

- - Defined in assets-manager/AssetsManager.ts:154

  处理url

  #### Parameters

  - ##### url: string

    url

  #### Returns string

  string 处理后的url

### setResCacheProxy

- setResCacheProxy(proxyFunc: Function): void

- - Defined in assets-manager/AssetsManager.ts:115

  #### Parameters

  - ##### proxyFunc: Function

  #### Returns void

### setResPath

- setResPath(path: string): void

- - Defined in assets-manager/AssetsManager.ts:62

  设置资源根路径

  #### Parameters

  - ##### path: string

  #### Returns void

Generated using TypeDoc