## Classes

Asset

资源操作接口

## Typedefs

IReturnData : object

## Asset
资源操作接口

**Kind**: global class  

* Asset
    * .loadAsset(object) ⇒ `Promise.`
    * .loadAssetList(object) ⇒ `Promise.`
    * .saveAsset(object) ⇒ `Promise.`
    * .getAllScenesPath() ⇒ `Promise`
    * .getAllPrefabPath() ⇒ `Promise`
    * .readFile(opt) ⇒ Promise.<IReturnData> \| `ArrayBuffer` \| `string`
    * .writeFile(opt) ⇒ Promise.<IReturnData>
    * .removeFile(opt) ⇒ Promise.<IReturnData>
    * .getFileOrDirStat(opt) ⇒ Promise.<IReturnData> \| `Stats`
    * .getUint64String(opt) ⇒ Promise.<IReturnData> \| `string`
    * .getAllFileListInDir(opt) ⇒ Promise.<IReturnData> \| `array` \| `string` \| `boolean` \| `string` \| `string` \| `string` \| `string`
    * .getSrcFileDepRelations() ⇒ Promise.<IReturnData> \| IReturnData \| `boolean`
    * .createSpriteFrameInfo(opt) ⇒ Promise.<IReturnData>
    * .getFileDefaultDataByType(opt) ⇒ Promise.<IReturnData>
    * .copyAssetsFile(opt) ⇒ Promise.<IReturnData> \| `\*`
    * .copyFiles(opt)
    * .addPrefab(assetPath, parentEntity, success, fail) ⇒ `Promise`
    * .createPrefabInfo(opt) ⇒ Promise.<IReturnData> \| `\*`
    * .requireScriptComponent(opt) ⇒ Promise.<IReturnData> \| `\*`
    * .getEditorCurrentRoot() ⇒ Promise.<IReturnData> \| `\*`
    * .checkPathExists(opt) ⇒ Promise.<IReturnData> \| `\*`
    * .createFolder(opt) ⇒ Promise.<IReturnData> \| `\*`
    * .showLoading(opt)
    * .hideLoading()
    * .addComponentAsync(entity, componentClassCtor) ⇒ `object`
    * .lockFocusTrigger()
    * .unlockFocusTrigger()
    * .setAssetAsEntry(opt)
    * .requireScript(filePath)
    * .getImageTextureUuid(opt) ⇒ `String`
    * .getMetaBySrcPath(assetPath) ⇒ `Object`
    * .getSubResrUuidBySrcUuid(uuid, subFileName)
    * .hasFileExists(filePath)
    * .locateProjectFileByPath(filePath)
    * .getUUIDByAssetsPath(path)
    * .checkIsEntryResourceByPath(path)
    * .getResourceTypeByUUID(uuid)
    * .getPathByUUID(uuid) ⇒ `string`
    * .getMetaByFileName(path)
    * .isProjectBuilding() ⇒ `Boolean`
    * .isPlayMode() ⇒ `Boolean`
    * .loadAssetSuccessCallback : `function`
    * .loadAssetFailCallback : `function`
    * .loadAssetListSuccessCallback : `function`
    * .loadAssetListFailCallback : `function`
    * .saveAssetSuccessCallback : `function`
    * .saveAssetFailCallback : `function`

### asset.loadAsset(object) ⇒ `Promise.`
加载单个资源

**Kind**: instance method of Asset  
**Returns**: `Promise.` - 返回一个Promise对象  

| Param | Type | Description |
| --- | --- | --- |
| object | `Object` |  |
| object.assetPath | `string` | 资源路径, 相对于 assets 的相对路径, 如: 路径为 assets/Assets/1.prefab, 则传入的path 是 Assets/1.prefab |
| object.success | loadAssetSuccessCallback | 注册成功回调 |
| object.fail | loadAssetFailCallback | 注册失败回调 |

**Example** *(Promise用法)*  
```js
GameEditor.asset.loadAsset({
  assetPath: 'myScene/1.prefab' // 传入资源路径, 相对于 assets 目录
}).then((entity) => {
  console.log(entity)
}).catch((errMsg) => {
  console.error(errMsg)
})
```
**Example** *(注册回调用法)*  
```js
GameEditor.asset.loadAsset({
  assetPath: 'myScene/1.prefab' // 传入资源路径, 相对于 assets 目录
  success: function(entity) {
    console.log(entity)
  },
  fail: function(errMsg) {
    console.error(errMsg)
  }
})
```

### asset.loadAssetList(object) ⇒ `Promise.`
加载多个资源

**Kind**: instance method of Asset  
**Returns**: `Promise.` - 返回一个Promise对象  

| Param | Type | Description |
| --- | --- | --- |
| object | `Object` |  |
| object.assetPathList | `string` | 资源路径数组 |
| object.success | loadAssetListSuccessCallback | 注册成功回调 |
| object.fail | loadAssetListFailCallback | 注册失败回调 |

**Example** *(Promise用法)*  
```js
GameEditor.asset.loadAsset({
  assetPathList: ['assetPathxxxxx'] // 传入资源路径
}).then((entity) => {
  console.log(entity)
}).catch((errMsg) => {
  console.error(errMsg)
})
```
**Example** *(注册回调用法)*  
```js
GameEditor.asset.loadAsset({
  assetPathList: ['assetPathxxxxx'] // 传入资源路径
  success: function(entity) {
    console.log(entity)
  },
  fail: function(errMsg) {
    console.error(errMsg)
  }
})
```

### asset.saveAsset(object) ⇒ `Promise.`
保存资源, 将内存中的内存对象落地到文件中

**Kind**: instance method of Asset  
**Returns**: `Promise.` - 返回一个Promise对象  

| Param | Type | Description |
| --- | --- | --- |
| object | `Object` |  |
| object.assetPath | `string` | 资源路径 |
| object.entity | `engine.Entity` | entity内存对象 |
| object.success | saveAssetSuccessCallback | 注册成功回调 |
| object.fail | saveAssetFailCallback | 注册失败回调 |

**Example** *(Promise用法)*  
```js
GameEditor.asset.loadAsset({
  assetPathList: ['assetPathxxxxx'] // 传入资源路径
}).then((entity) => {
  console.log(entity)
}).catch((errMsg) => {
  console.error(errMsg)
})
```
**Example** *(注册回调用法)*  
```js
GameEditor.asset.loadAsset({
  assetPathList: ['assetPathxxxxx'] // 传入资源路径
  success: function(entity) {
    console.log(entity)
  },
  fail: function(errMsg) {
    console.error(errMsg)
  }
})
```

### asset.getAllScenesPath() ⇒ `Promise`
获取所有Scene资源路径

**Kind**: instance method of Asset  
**Returns**: `Promise` - 

Promise.reject {string} errMsg 错误信息 

Promise.resolve {array} data 所有Scene资源路径 

**Example** *(获取所有Scene资源路径)*  
```js
const scenePathList = GameEditor.getAllScenesPath()
console.log(scenePathList)
```

### asset.getAllPrefabPath() ⇒ `Promise`
获取所有Prefab资源路径

**Kind**: instance method of Asset  
**Returns**: `Promise` - 返回资源路径数组 

Promise.reject {string} errMsg 错误信息 

Promise.resolve {array} data 所有Prefab资源路径 

**Example** *(获取所有Prefab资源路径)*  
```js
const prefabPathList = GameEditor.getAllPrefabPathSync()
console.log(prefabPathList)
```

### asset.readFile(opt) ⇒ Promise.<IReturnData> \| `ArrayBuffer` \| `string`
读取文件内容

**Kind**: instance method of Asset  
**Returns**: Promise.<IReturnData> - Promise返回IReturnData结构数据 
`ArrayBuffer` \| `string` - IReturnData.data 文件内容。当传入opt.encoding时，以string形式返回指定编码文件信息。否则，以ArrayBuffer形式返回文件信息  

| Param | Type | Description |
| --- | --- | --- |
| opt | `object` |  |
| opt.file | `string` | 文件相对路径（相对于小程序项目目录） |
| opt.encoding | `string` | 读取文件时使用的编码。具体值可参考[Node.js文档](https://nodejs.org/dist/latest/docs/api/buffer.html#buffer_class_method_buffer_from_string_encoding)中Buffer.from函数里encoding支持的值。为空时，以ArrayBuffer形式返回文件信息；非空时，以string形式返回指定编码文件信息。 |

**Example** *(readFile示例1：)*  
```js
const fileObject = await window.GameEditor.assets.readFile({
   file: 'a/b.js', // 读取小程序项目目录下 a/b.js 文件内容
   encoding: 'utf8' // 以utf8编码读取文件内容
});
if (fileObject.isSuccess) {
   console.log('读取成功');
} else {
   console.log('读取失败，失败原因：' + fileObject.errMsg);
}
```
**Example** *(readFile示例2：)*  
```js
const fileObject = await window.GameEditor.assets.readFile({
   file: 'a/b.js', // 读取小程序项目目录下 a/b.js 文件内容
});
if (fileObject.isSuccess && fileObject.data) {
   const dv = new DataView(fileObject.data);
   dv.getInt16(8);
}
```

### asset.writeFile(opt) ⇒ Promise.<IReturnData>
写入文件内容

**Kind**: instance method of Asset  

| Param | Type | Default | Description |
| --- | --- | --- | --- |
| opt | `object` |  |  |
| opt.file | `string` |  | 文件相对路径（相对于小程序项目目录的assets目录） |
| opt.content | `string` |  | 写入的文件内容 |
| opt.encoding | `string` | `"utf8"` | 写入文件时使用的编码。具体值可参考[Node.js文档](https://nodejs.org/dist/latest/docs/api/buffer.html#buffer_class_method_buffer_from_string_encoding)中Buffer.from函数里encoding支持的值。默认utf8 |

**Example** *(writeFile示例：)*  
```js
const writeFileResult = await window.GameEditor.assets.writeFile({
   file: 'a/b.js', // 往小程序项目目录下 assets/a/b.js 写入指定内容
   content: 'this is file content',
   encoding: 'utf8' // 可以不填，默认为utf8
});
if (writeFileResult.isSuccess) {
   console.log('写入成功');
} else {
   console.log('写入失败，失败原因：' + writeFileResult.errMsg);
}
```

### asset.removeFile(opt) ⇒ Promise.<IReturnData>
删除文件

**Kind**: instance method of Asset  

| Param | Type | Description |
| --- | --- | --- |
| opt | `object` |  |
| opt.file | `string` | 文件相对路径（相对于小程序项目目录的assets目录） |

**Example** *( removeFile示例：)*  
```js
const stats = await window.GameEditor.assets.removeFile({
   path: 'a/b.js', // 小程序项目目录下文件 a/b.js
});
if (stats.isSuccess) {
   console.log('删除文件成功');
} else {
   console.log('删除文件失败，失败原因：' + stats.errMsg);
}
```

### asset.getFileOrDirStat(opt) ⇒ Promise.<IReturnData> \| `Stats`
获取指定文件夹或文件状态

**Kind**: instance method of Asset  
**Returns**: Promise.<IReturnData> - Promise返回IReturnData结构数据 
`Stats` - IReturnData.data 文件或文件夹状态。详情可参考[Node.js文档](https://nodejs.org/dist/latest/docs/api/fs.html#fs_class_fs_stats)中fs.Stats结构  

| Param | Type | Description |
| --- | --- | --- |
| opt | `object` |  |
| opt.path | `string` | 文件或文件夹相对路径（相对于小程序项目目录） |

**Example** *(getFileOrDirStat示例：)*  
```js
const stats = await window.GameEditor.assets.getFileOrDirStat({
   path: 'a/b.js', // 小程序项目目录下文件 a/b.js
});
if (stats.isSuccess) {
   console.log('获取状态成功');
   console.log('atimeMs：' + stats.data.atimeMs);
} else {
   console.log('获取状态失败，失败原因：' + stats.errMsg);
}
```

### asset.getUint64String(opt) ⇒ Promise.<IReturnData> \| `string`
将64位无符号整型转成字符串

**Kind**: instance method of Asset  
**Returns**: Promise.<IReturnData> - Promise返回IReturnData结构数据 
`string` - IReturnData.data 由opt.uint8Array转化的64位无符号整型字符串  

| Param | Type | Description |
| --- | --- | --- |
| opt | `object` |  |
| opt.uint8Array | `Uint8Array` | 64位无符号整型组成的长度为8的Uint8Array，数据必须是大端字节序 |

**Example** *(getUint64String示例：)*  
```js
const fileObject = await window.GameEditor.assets.readFile({
   file: 'a/b.js', // 读取小程序项目目录下 a/b.js 文件内容
});
if (fileObject.isSuccess && fileObject.data) {
   // 将读取的a/b.js文件头8个字节组成的64位无符号整型转成字符串。注意：数据本身符合大端字节序
   const id = await window.GameEditor.assets.getUint64String({
      uint8Array: new Uint8Array(fileObject.data, 0, 8);
   });
}
```

### asset.getAllFileListInDir(opt) ⇒ Promise.<IReturnData> \| `array` \| `string` \| `boolean` \| `string` \| `string` \| `string` \| `string`
获取指定目录下的文件信息（不包含文件内容）

**Kind**: instance method of Asset  
**Returns**: Promise.<IReturnData> - Promise返回IReturnData结构数据 
`array` - IReturnData.data 查询到的文件列表信息 
`string` - data[].path 文件或文件夹相对小程序项目路径 
`boolean` - data[].isFile true：文件；false：目录 
`string` - data[].name 如果是文件，表示不带扩展名的文件名。如果是文件夹，此字段undefined 
`string` - data[].dir 如果是文件，表示文件的父目录，相对小程序项目。如果是文件夹，此字段undefined 
`string` - data[].base 如果是文件，表示带扩展名的文件名。如果是文件夹，此字段undefined 
`string` - data[].ext 如果是文件，表示扩展名，如.exe。如果是文件夹，此字段undefined 


| Param | Type | Default | Description |
| --- | --- | --- | --- |
| opt | `object` |  |  |
| opt.path | `string` |  | 目录相对路径（相对于小程序项目目录） |
| opt.includeDir | `boolean` | `false` | true：子目录信息也会返回。false：只返回文件信息 |
| opt.recursive | `boolean` | `false` | true：递归返回opt.path及其子目录所有信息；false：只返回opt.path 下信息 |

**Example** *(getAllFileListInDir示例：)*  
```js
const filesListResult = await window.GameEditor.assets.getAllFileListInDir({
   path: 'a/b', // 在小程序项目目录下 a/b 目录查找
   includeDir: false, // 只返回文件信息
   recursive: true, // 深度遍历子目录
});
if (!filesListResult.isSuccess) { // 失败
   console.log('失败原因：' + filesListResult.errMsg);
}
if (filesListResult.data.length === 0) { // 没有文件
   console.log('文件夹下没有文件');
}
const task = []; // 读取文件任务
const filesList = filesListResult.data; // 文件列表
for (let i = 0, il = filesList.length; i < il; i++) {
   let a = filesList[i];
   if (a.isFile && a.ext === '.txt') { // 如果是文件且扩展名是.txt
     task.push((async () => { // 创建任务
       let fileObject: object = await window.GameEditor.assets.readFile({ // 读取文件内容，返回ArrayBuffer
          file: a.path // a.path是文件相对于小程序项目目录路径
       });
       return fileObject;
     }) ());
   }
}
const fileObjects = await Promise.all(task); // 执行读取文件任务
```

### asset.getSrcFileDepRelations() ⇒ Promise.<IReturnData> \| IReturnData \| `boolean`
从srcMetaManager获取项目source目录下的文件信息

**Kind**: instance method of Asset  

### asset.createSpriteFrameInfo(opt) ⇒ Promise.<IReturnData>
根据指定texture2d图片信息，在assets目录下生成spriteframe信息。生成后的spriteframe文件目录结构跟texture2d目录结构保持一致

**Kind**: instance method of Asset  
**Returns**: Promise.<IReturnData> - Promise返回IReturnData结构数据  

| Param | Type | Description |
| --- | --- | --- |
| opt | `object` |  |
| opt.distPath | `string` | 目标目录相对路径（相对于assets目录） |
| opt.imgInfo | `object` | texture2d图片文件信息 |
| imgInfo.imgPath | `string` | texture2d图片相对路径（相对于小程序根目录） |
| imgInfo.texture2dData | `object` | texture2d图片信息。默认数据结构需通过getFileDefaultDataByType获取 |
| opt.rect | `Array` | texture2d图片里的spriteframe区域块信息 |
| rect[].id | `string` | 区域id，用于生成spritefram描述文件名 |
| rect[].x | `number` | 区域左上角x坐标（texture2d图片左上角坐标为(0，0)） |
| rect[].y | `number` | 区域左上角y坐标 |
| rect[].w | `number` | 区域长度 |
| rect[].h | `number` | 区域宽度 |

**Example** *(获取texture2d默认数据，并生成spriteframe文件)*  
```js
const texture2dResult = window.GameEditor.assets.getFileDefaultDataByType({
   type: 'texture2d'
});
if (!texture2dResult.isSuccess) { // 失败
   console.log('失败原因：' + texture2dResult.errMsg);
}

// 根据图片信息，设置对应字段
const texture2dDefaultData = texture2dResult.data;
texture2dDefaultData.width = 128; // 图片宽度
texture2dDefaultData.height = 128; // 图片高度
// todo set any other texture2d info

// 创建spriteframe文件
const spriteFrameResult = await window.GameEditor.assets.createSpriteFrameInfo({
   distPath: 'customerSpriteFrame', // 生成的文件输出到 assets/customerSpriteFrame 目录下
   imgInfo: {
      imgPath: 'a/b.png', // texture2d图片相对路径，即小程序项目目录下 a/b.png
      texture2dData: texture2dDefaultData // a/b.png texture2d图片的信息
   },
   rect: [{ // a/b.png图片的spriteframe信息
     id: 'i_am_id',
     x: 0,
     y: 0,
     h: 10,
     w: 10
   }]
});
if (!spriteFrameResult.isSuccess) {
   console.log('失败原因：' + texture2dResult.errMsg);
} else {
   console.log('成功');
}
```

### asset.getFileDefaultDataByType(opt) ⇒ Promise.<IReturnData>
根据类型获取对应文件数据结构

**Kind**: instance method of Asset  
**Returns**: Promise.<IReturnData> - Promise返回IReturnData结构数据 


| Param | Type | Description |
| --- | --- | --- |
| opt | `object` |  |
| opt.type | `string` | 文件类型。folder，2dScene，3dScene，2dPrefab，3dPrefab，spriteframe，font，texture2d，material，effect |

**Example** *(获取texture2d默认数据，并生成spriteframe文件)*  
```js
const texture2dResult = window.GameEditor.assets.getFileDefaultDataByType({
   type: 'texture2d'
});
if (!texture2dResult.isSuccess) { // 失败
   console.log('失败原因：' + texture2dResult.errMsg);
}

// 根据图片信息，设置对应字段
const texture2dDefaultData = texture2dResult.data;
texture2dDefaultData.width = 128; // 图片宽度
texture2dDefaultData.height = 128; // 图片高度
// todo set any other texture2d info

// 创建spriteframe文件
const spriteFrameResult = await window.GameEditor.assets.createSpriteFrameInfo({
   distPath: 'customerSpriteFrame', // 生成的文件输出到 assets/customerSpriteFrame 目录下
   imgInfo: {
      imgPath: 'a/b.png', // texture2d图片相对路径，即小程序项目目录下 a/b.png
      texture2dData: texture2dDefaultData // a/b.png texture2d图片的信息
   },
   rect: [{ // a/b.png图片的spriteframe信息
     id: 'i_am_id',
     x: 0,
     y: 0,
     h: 10,
     w: 10
   }]
});
if (!spriteFrameResult.isSuccess) {
   console.log('失败原因：' + texture2dResult.errMsg);
} else {
   console.log('成功');
}
```

### asset.copyAssetsFile(opt) ⇒ Promise.<IReturnData> \| `\*`
拷贝资源

**Kind**: instance method of Asset  
**Returns**: Promise.<IReturnData> - Promise返回IReturnData结构数据 
`\*` - IReturnData.data 对应类型的默认数据结构  

| Param | Type | Description |
| --- | --- | --- |
| opt | `object` |  |
| opt.fileList | `Array` | 拷贝资源的路径数组fileList[],路径为相对assets目录的路径 |
| opt.targetPath | `String` | 拷贝资源的目标路径（相对于assets目录） |

### asset.copyFiles(opt)
拷贝文件

**Kind**: instance method of Asset  

| Param | Type | Description |
| --- | --- | --- |
| opt | `object` |  |
| opt.srcDstInfos | `Array` | Array 路径为相对小游戏项目的根路径 |
| opt.options | `object` |  |

### asset.addPrefab(assetPath, parentEntity, success, fail) ⇒ `Promise`
添加prefab

**Kind**: instance method of Asset  
**Returns**: `Promise` - 返回一个Promise对象 


| Param | Type | Description |
| --- | --- | --- |
| assetPath | `String` | 添加的prefab资源路径 |
| parentEntity | `engine.Entity` | 被添加的entity |
| success | `function` | 成功的回调 |
| fail | `function` | 失败的回调 |

**Example** *(add示例)*  
```js
const result = await GameEditor.asset.addPrefab({
  assetPath: "a.prefab",
  parentEntity: "entity",
}).then((entity)=>{
  console.log(entity)
}).catch((err)=>{
  console.error(err)
})
```

### asset.createPrefabInfo(opt) ⇒ Promise.<IReturnData> \| `\*`
创建UIprefab

**Kind**: instance method of Asset  
**Returns**: Promise.<IReturnData> - Promise返回IReturnData结构数据 
`\*` - IReturnData.data 对应类型的默认数据结构  

| Param | Type | Description |
| --- | --- | --- |
| opt | `object` |  |
| opt.assetPath | `Array` | 创建的资源路径 |

**Example** *(createPrefabInfo示例)*  
```js
const result = await GameEditor.asset.createPrefabInfo({
  assetPath: "newfile.prefab"",
})
if (!result.isSuccess) { // 失败
  console.log('失败原因：' + result.errMsg);
} else { // 成功
  console.log('成功')
}
```

### asset.requireScriptComponent(opt) ⇒ Promise.<IReturnData> \| `\*`
requireScriptComponent

**Kind**: instance method of Asset  
**Returns**: Promise.<IReturnData> - Promise返回IReturnData结构数据 
`\*` - IReturnData.data 对应类型的默认数据结构  

| Param | Type | Description |
| --- | --- | --- |
| opt | `object` |  |
| opt.scriptPath | `String` | 脚本资源路径 |
| opt.component | `engine.Script` | 自定义组件 |

### asset.getEditorCurrentRoot() ⇒ Promise.<IReturnData> \| `\*`
获取编辑器当前的root节点, sceneRoot或者prefabRoot

**Kind**: instance method of Asset  
**Returns**: Promise.<IReturnData> - Promise返回IReturnData结构数据 
`\*` - IReturnData.data 对应类型的默认数据结构  

### asset.checkPathExists(opt) ⇒ Promise.<IReturnData> \| `\*`
校验assets目录下文件路径是否存在

**Kind**: instance method of Asset  
**Returns**: Promise.<IReturnData> - Promise返回IReturnData结构数据 
`\*` - IReturnData.data 对应类型的默认数据结构  

| Param | Type | Description |
| --- | --- | --- |
| opt | `object` |  |
| opt.path | `String` | 校验路径 |

### asset.createFolder(opt) ⇒ Promise.<IReturnData> \| `\*`
创建文件夹

**Kind**: instance method of Asset  
**Returns**: Promise.<IReturnData> - Promise返回IReturnData结构数据 
`\*` - IReturnData.data 对应类型的默认数据结构  

| Param | Type | Description |
| --- | --- | --- |
| opt | `object` |  |
| opt.folderPath | `String` | 文件夹路径 |
| opt.folderName | `String` | 文件夹名称 |

### asset.showLoading(opt)
显示loading

**Kind**: instance method of Asset  

| Param | Type | Description |
| --- | --- | --- |
| opt | `object` |  |
| opt.key | `String` | loading关键词 |
| opt.msg | `String` | loading显示的title |

### asset.hideLoading()
隐藏loading

**Kind**: instance method of Asset  

| Param | Type | Description |
| --- | --- | --- |
| opt.key | `String` | loading关键词 |

### asset.addComponentAsync(entity, componentClassCtor) ⇒ `object`
添加对应的Component到对应的entity(会绑定uuid,否则无法建立依赖关系)

**Kind**: instance method of Asset  
**Returns**: `object` - { names: string[], srcPath: string, uuid: string, pathDeps: string[]}  

| Param | Type | Description |
| --- | --- | --- |
| entity | `object` | 要添加的entity对象 |
| componentClassCtor | `function` | component类 |

### asset.lockFocusTrigger()
启动以后，屏幕的focus不会触发编译

**Kind**: instance method of Asset  

### asset.unlockFocusTrigger()
释放，屏幕的focus会触发编译

**Kind**: instance method of Asset  

### asset.setAssetAsEntry(opt)
资源设置为入口资源

**Kind**: instance method of Asset  

| Param | Type | Description |
| --- | --- | --- |
| opt | `object` |  |
| opt.path | `String` | 资源路径 |

### asset.requireScript(filePath)
用户手动require脚本

**Kind**: instance method of Asset  

| Param | Type |
| --- | --- |
| filePath | `string` | 

### asset.getImageTextureUuid(opt) ⇒ `String`
获取图片的texture uuid

**Kind**: instance method of Asset  
**Returns**: `String` - texture uuid  

| Param | Type | Description |
| --- | --- | --- |
| opt | `object` |  |
| opt.path | `String` | 图片的路径 |

### asset.getMetaBySrcPath(assetPath) ⇒ `Object`
获取资源的meta信息

**Kind**: instance method of Asset  
**Returns**: `Object` - meta 信息  

| Param | Type | Description |
| --- | --- | --- |
| assetPath | `String` | 资源路径 |

### asset.getSubResrUuidBySrcUuid(uuid, subFileName)
获取图片相关的spriteframe的uuid

**Kind**: instance method of Asset  

| Param | Type | Description |
| --- | --- | --- |
| uuid | `String` | 资源的uuid |
| subFileName | `String` | 关联的资源名，如spriteframe |

### asset.hasFileExists(filePath)
判断文件是否存在

**Kind**: instance method of Asset  

| Param | Type | Description |
| --- | --- | --- |
| filePath | `String` | 文件路径相对于 assets/ |

### asset.locateProjectFileByPath(filePath)
展开project层级树

**Kind**: instance method of Asset  

| Param | Type | Description |
| --- | --- | --- |
| filePath | `string` | 文件路径相对于 assets/ |

### asset.getUUIDByAssetsPath(path)
获取文件的uuid

**Kind**: instance method of Asset  

| Param | Type | Description |
| --- | --- | --- |
| path | `string` | 文件路径相对于 assets/ |

### asset.checkIsEntryResourceByPath(path)
判断文件

**Kind**: instance method of Asset  

| Param | Type | Description |
| --- | --- | --- |
| path | `string` | 文件路径相对于 assets/ |

### asset.getResourceTypeByUUID(uuid)
通过uuid获取资源类型

**Kind**: instance method of Asset  

| Param | Type | Description |
| --- | --- | --- |
| uuid | `string` | 资源的uuid |

### asset.getPathByUUID(uuid) ⇒ `string`
通过uuid获取资源路径

**Kind**: instance method of Asset  
**Returns**: `string` - 资源路径  

| Param | Type | Description |
| --- | --- | --- |
| uuid | `string` | 资源的uuid |

### asset.getMetaByFileName(path)
获取文件meta

**Kind**: instance method of Asset  

| Param | Type | Description |
| --- | --- | --- |
| path | `string` | 文件路径相对于 assets/ |

### asset.isProjectBuilding() ⇒ `Boolean`
项目是否正在构建中

**Kind**: instance method of Asset  
**Returns**: `Boolean` - 返回true或者是false  

### asset.isPlayMode() ⇒ `Boolean`
工具是否在播放态

**Kind**: instance method of Asset  
**Returns**: `Boolean` - 返回true或者是false  

### asset.loadAssetSuccessCallback : `function`
loadAsset 成功回调

**Kind**: instance typedef of Asset  

| Param | Type | Description |
| --- | --- | --- |
| entity | `engine.Entity` | assetPath对应的Entity内存对象 |

### asset.loadAssetFailCallback : `function`
loadAsset 失败回调

**Kind**: instance typedef of Asset  

| Param | Type | Description |
| --- | --- | --- |
| errMsg | `string` | 错误信息 |

### asset.loadAssetListSuccessCallback : `function`
loadAssetList 成功回调

**Kind**: instance typedef of Asset  

| Param | Type | Description |
| --- | --- | --- |
| entity | `engine.Entity` | assetPath对应的Entity内存对象 |

### asset.loadAssetListFailCallback : `function`
loadAssetList 失败回调

**Kind**: instance typedef of Asset  

| Param | Type | Description |
| --- | --- | --- |
| errMsg | `string` | 错误信息 |

### asset.saveAssetSuccessCallback : `function`
saveAsset 成功回调

**Kind**: instance typedef of Asset  

| Param | Type | Description |
| --- | --- | --- |
| entity | `engine.Entity` | assetPath对应的Entity内存对象 |

### asset.saveAssetFailCallback : `function`
saveAsset 失败回调

**Kind**: instance typedef of Asset  

| Param | Type | Description |
| --- | --- | --- |
| errMsg | `string` | 错误信息 |

## IReturnData : `object`
**Kind**: global typedef  
**Properties**

| Name | Type | Description |
| --- | --- | --- |
| isSuccess | `boolean` | true：成功， false：失败 |
| errMsg | `string` | 错误信息 |
| data | `\*` | 接口返回的数据。详见具体接口说明 |
