diff --git a/cocos/assets/CCAssetLibrary.ts b/cocos/assets/CCAssetLibrary.ts
index 13cd449ec4..c26dd6a9a0 100644
--- a/cocos/assets/CCAssetLibrary.ts
+++ b/cocos/assets/CCAssetLibrary.ts
@@ -36,13 +36,6 @@ import { Asset } from './asset';
// tslint:disable: max-line-length
-/**
- * The asset library which managing loading/unloading assets in project.
- *
- * @class AssetLibrary
- * @static
- */
-
// configs
let _libraryBase = '';
@@ -62,11 +55,14 @@ function RawAssetEntry (url, type) {
// publics
+/**
+ * 管理项目中加载/卸载资源的资源库。
+ * @class AssetLibrary
+ * @static
+ */
const AssetLibrary = {
/**
- * !#en Caches uuid to all loaded assets in scenes.
- *
- * !#zh 这里保存所有已经加载的场景资源,防止同一个资源在内存中加载出多份拷贝。
+ * 这里保存所有已经加载的场景资源,防止同一个资源在内存中加载出多份拷贝。
*
* 这里用不了WeakMap,在浏览器中所有加载过的资源都只能手工调用 unloadAsset 释放。
*
@@ -86,16 +82,17 @@ const AssetLibrary = {
*/
/**
+ * @zh
+ * 加载资源
* @method loadAsset
* @param {String} uuid
- * @param {loadCallback} callback - the callback function once load finished
+ * @param {loadCallback} callback - 加载完成后执行的回调函数
* @param {Object} options
- * @param {Boolean} options.readMainCache - Default is true. If false, the asset and all its depends assets will reload and create new instances from library.
- * @param {Boolean} options.writeMainCache - Default is true. If true, the result will cache to AssetLibrary, and MUST be unload by user manually.
- * @param {Asset} options.existingAsset - load to existing asset, this argument is only available in editor
- * @private
+ * @param {Boolean} options.readMainCache - 默认为true。如果为false,则资源及其所有依赖资源将重新加载并从库中创建新实例。
+ * @param {Boolean} options.writeMainCache - 默认为true。如果为true,则结果将缓存到 AssetLibrary,并且必须由用户手动卸载。
+ * @param {Asset} options.existingAsset - 加载现有资源,此参数仅在编辑器中可用
*/
- loadAsset (uuid, callback, options) {
+ loadAsset (uuid: String, callback: Function, options) {
if (typeof uuid !== 'string') {
return callInNextTick(callback, new Error('[AssetLibrary] uuid must be string'), null);
}
@@ -129,6 +126,10 @@ const AssetLibrary = {
});
},
+ /**
+ * @zh
+ * 获取资源的 url
+ */
getLibUrlNoExt (uuid, inRawAssetsDir?: boolean) {
if (CC_BUILD) {
uuid = decodeUuid(uuid);
@@ -137,6 +138,12 @@ const AssetLibrary = {
return base + uuid.slice(0, 2) + '/' + uuid;
},
+ /**
+ * @zh
+ * 在编辑器中查询资源信息
+ * @param uuid 资源的 uuid
+ * @protected
+ */
_queryAssetInfoInEditor (uuid, callback) {
if (CC_EDITOR) {
Editor.Ipc.sendToMain('scene:query-asset-info-by-uuid', uuid, (err, info) => {
@@ -160,6 +167,10 @@ const AssetLibrary = {
}
},
+ /**
+ * @zh
+ * 在运行时获取资源信息
+ */
_getAssetInfoInRuntime (uuid, result?: any) {
result = result || {url: null, raw: false};
const info = _uuidToRawAsset[uuid];
@@ -175,13 +186,18 @@ const AssetLibrary = {
return result;
},
+ /**
+ * @zh
+ * 在 setting 中的 uuid
+ */
_uuidInSettings (uuid) {
return uuid in _uuidToRawAsset;
},
/**
- * @method queryAssetInfo
- * @param {String} uuid
+ * @zh
+ * 获取资源信息
+ * @param {String} uuid 资源的 uuid
* @param {Function} callback
* @param {Error} callback.error
* @param {String} callback.url - the url of raw asset or imported asset
@@ -198,7 +214,13 @@ const AssetLibrary = {
}
},
- // parse uuid out of url
+ /**
+ * @en
+ * parse uuid out of url
+ * @zh
+ * 从 url 解析 uuid
+ * @param url 资源地址
+ */
parseUuidInEditor (url) {
if (CC_EDITOR) {
let uuid = '';
@@ -226,7 +248,8 @@ const AssetLibrary = {
},
/**
- * @method loadJson
+ * @zh
+ * 加载 json
* @param {String} json
* @param {loadCallback} callback
* @return {LoadingHandle}
@@ -262,11 +285,13 @@ const AssetLibrary = {
},
/**
+ * @en
* Get the exists asset by uuid.
- *
+ * @zh
+ * 根据 uuid 获取存在的资源
* @method getAssetByUuid
* @param {String} uuid
- * @return {Asset} - the existing asset, if not loaded, just returns null.
+ * @return {Asset} - 返回存在的资源,若没有加载则返回 null
* @private
*/
getAssetByUuid (uuid) {
@@ -275,8 +300,10 @@ const AssetLibrary = {
// tslint:disable: no-shadowed-variable
/**
+ * @en
* init the asset library
- *
+ * @zh
+ * 初始化 AssetLibrary
* @method init
* @param {Object} options
* @param {String} options.libraryPath - 能接收的任意类型的路径,通常在编辑器里使用绝对的,在网页里使用相对的。
diff --git a/cocos/assets/CCJsonAsset.ts b/cocos/assets/CCJsonAsset.ts
index 6a4154b153..82c794611d 100644
--- a/cocos/assets/CCJsonAsset.ts
+++ b/cocos/assets/CCJsonAsset.ts
@@ -27,6 +27,7 @@ import {ccclass, property} from '../core/data/class-decorator';
import { Asset } from './asset';
/**
+ * @zh
* Json 资源。
* Json 资源加载后将直接解析为对象。如果你希望获得 JSON 的原始文本,你需要使用文本资源(使用文件名后缀“.txt”)。
*/
diff --git a/cocos/assets/CCPrefab.ts b/cocos/assets/CCPrefab.ts
index 3e2ace45a5..34e40e98ca 100644
--- a/cocos/assets/CCPrefab.ts
+++ b/cocos/assets/CCPrefab.ts
@@ -31,55 +31,34 @@ import Enum from '../core/value-types/enum';
import { Asset } from './asset';
/**
- * !#zh
- * Prefab 创建实例所用的优化策略,配合 {{#crossLink "Prefab.optimizationPolicy"}}cc.Prefab#optimizationPolicy{{/crossLink}} 使用。
- * !#en
- * An enumeration used with the {{#crossLink "Prefab.optimizationPolicy"}}cc.Prefab#optimizationPolicy{{/crossLink}}
- * to specify how to optimize the instantiate operation.
+ * Prefab 创建实例所用的优化策略,配合 [[optimizationPolicy]] 使用。
*
* @enum Prefab.OptimizationPolicy
* @since 1.10.0
*/
const OptimizationPolicy = Enum({
/**
- * !#zh
* 根据创建次数自动调整优化策略。初次创建实例时,行为等同 SINGLE_INSTANCE,多次创建后将自动采用 MULTI_INSTANCE。
- * !#en
- * The optimization policy is automatically chosen based on the number of instantiations.
- * When you first create an instance, the behavior is the same as SINGLE_INSTANCE. MULTI_INSTANCE will be automatically used after multiple creation.
* @property {Number} AUTO
*/
AUTO: 0,
/**
- * !#zh
* 优化单次创建性能。
* 该选项会跳过针对这个 prefab 的代码生成优化操作。当该 prefab 加载后,一般只会创建一个实例时,请选择此项。
- * !#en
- * Optimize for single instance creation.
- * This option skips code generation for this prefab.
- * When this prefab will usually create only one instances, please select this option.
* @property {Number} SINGLE_INSTANCE
*/
SINGLE_INSTANCE: 1,
/**
- * !#zh
* 优化多次创建性能。
* 该选项会启用针对这个 prefab 的代码生成优化操作。当该 prefab 加载后,一般会创建多个实例时,请选择此项。如果该 prefab 在场景中的节点启用了自动关联,并且在场景中有多份实例,也建议选择此项。
- * !#en
- * Optimize for creating instances multiple times.
- * This option enables code generation for this prefab.
- * When this prefab will usually create multiple instances, please select this option.
- * It is also recommended to select this option if the prefab instance in the scene has Auto Sync enabled and there are multiple instances in the scene.
* @property {Number} MULTI_INSTANCE
*/
MULTI_INSTANCE: 2,
});
/**
- * !#en Class for prefab handling.
- * !#zh 预制资源类。
- * @class Prefab
- * @extends Asset
+ * @en Class for prefab handling.
+ * @zh 预制资源类。
*/
@ccclass('cc.Prefab')
export default class Prefab extends Asset {
@@ -94,9 +73,9 @@ export default class Prefab extends Asset {
public data: any = null;
/**
- * !#zh
+ * @zh
* 设置实例化这个 prefab 时所用的优化策略。根据使用情况设置为合适的值,能优化该 prefab 实例化所用的时间。
- * !#en
+ * @en
* Indicates the optimization policy for instantiating this prefab.
* Set to a suitable value based on usage, can optimize the time it takes to instantiate this prefab.
*
@@ -104,19 +83,20 @@ export default class Prefab extends Asset {
* @default Prefab.OptimizationPolicy.AUTO
* @since 1.10.0
* @example
+ * ```typescript
* prefab.optimizationPolicy = cc.Prefab.OptimizationPolicy.MULTI_INSTANCE;
+ * ```
*/
@property
public optimizationPolicy = OptimizationPolicy.AUTO;
/**
- * !#en Indicates the raw assets of this prefab can be load after prefab loaded.
- * !#zh 指示该 Prefab 依赖的资源可否在 Prefab 加载后再延迟加载。
- * @property {Boolean} asyncLoadAssets
+ * @en Indicates the raw assets of this prefab can be load after prefab loaded.
+ * @zh 指示该 Prefab 依赖的资源可否在 Prefab 加载后再延迟加载。
* @default false
*/
@property
- public asyncLoadAssets = false;
+ public asyncLoadAssets: Boolean = false;
private _createFunction: Function | null;
private _instantiatedTimes: number;
@@ -139,9 +119,14 @@ export default class Prefab extends Asset {
}
/**
+ * @en
* Dynamically translation prefab data into minimized code.
- * This method will be called automatically before the first time the prefab being instantiated,
+ * This method will be called automatically before the first time the prefab being instantiated,
* but you can re-call to refresh the create function once you modified the original prefab data in script.
+ * @zh
+ * 将预制数据动态转换为最小化代码
+ * 此方法将在第一次实例化预制件之前自动调用,
+ * 但是您可以在脚本中修改原始预制数据后重新调用以刷新创建功能。
* @method compileCreateFunction
*/
public compileCreateFunction (): void {
diff --git a/cocos/assets/CCSceneAsset.ts b/cocos/assets/CCSceneAsset.ts
index 7f92281517..948aa54574 100644
--- a/cocos/assets/CCSceneAsset.ts
+++ b/cocos/assets/CCSceneAsset.ts
@@ -29,7 +29,11 @@ import { Scene } from '../scene-graph';
import { Asset } from './asset';
/**
- * 场景资源。
+ * @en Class for scene handling.
+ * @zh 场景资源类。
+ * @class SceneAsset
+ * @extends Asset
+ *
*/
@ccclass('cc.SceneAsset')
export default class SceneAsset extends Asset {
@@ -40,7 +44,10 @@ export default class SceneAsset extends Asset {
public scene: Scene | null = null;
/**
- * 指示该场景依赖的资源可否在场景切换后再延迟加载。
+ * @en Indicates the raw assets of this scene can be load after scene launched.
+ * @zh 指示该场景依赖的资源可否在场景切换后再延迟加载。
+ * @property {Boolean} asyncLoadAssets
+ * @default false
*/
@property
public asyncLoadAssets = false;
diff --git a/cocos/assets/CCScripts.ts b/cocos/assets/CCScripts.ts
index bd50154c2e..2a439cbe73 100644
--- a/cocos/assets/CCScripts.ts
+++ b/cocos/assets/CCScripts.ts
@@ -28,6 +28,7 @@ import {ccclass} from '../core/data/class-decorator';
import { Asset } from './asset';
/**
+ * @zh
* 脚本资源基类。
*/
@ccclass('cc.Script')
@@ -36,6 +37,7 @@ export class Script extends Asset {
cc._Script = Script;
/**
+ * @zh
* JavaScript 脚本资源。
*/
@ccclass('cc.JavaScript')
@@ -44,6 +46,7 @@ export class JavaScript extends Script {
cc._JavaScript = JavaScript;
/**
+ * @zh
* Typescript 脚本资源。
*/
@ccclass('cc.TypeScript')
diff --git a/cocos/assets/CCTextAsset.ts b/cocos/assets/CCTextAsset.ts
index 1f575ddcf3..45aeb24a36 100644
--- a/cocos/assets/CCTextAsset.ts
+++ b/cocos/assets/CCTextAsset.ts
@@ -28,7 +28,8 @@ import {ccclass, property} from '../core/data/class-decorator';
import { Asset } from './asset';
/**
- * 文本资源。
+ * @en Class for text file.
+ * @zh 文本资源。
*/
@ccclass('cc.TextAsset')
export default class TextAsset extends Asset {
@@ -39,6 +40,7 @@ export default class TextAsset extends Asset {
public text = '';
/**
+ * @zh
* 重载标准的 `toString()` 方法。
*/
public toString () {
diff --git a/cocos/assets/asset-enum.ts b/cocos/assets/asset-enum.ts
index e2b5cfc00e..2f675b0e5b 100644
--- a/cocos/assets/asset-enum.ts
+++ b/cocos/assets/asset-enum.ts
@@ -1,46 +1,78 @@
import { GFXAddress, GFXFilter, GFXFormat } from '../gfx/define';
/**
- * The texture pixel format, default value is RGBA8888,
- * you should note that textures loaded by normal image files (png, jpg) can only support RGBA8888 format,
+ * @en
+ * The texture pixel format, default value is RGBA8888,
+ * you should note that textures loaded by normal image files (png, jpg) can only support RGBA8888 format,
* other formats are supported by compressed file types or raw data.
+ * @zh
+ * 纹理像素格式,默认值为RGBA8888,
+ * 你应该注意到普通图像文件(png,jpg)加载的纹理只能支持RGBA8888格式,
+ * 压缩文件类型或原始数据支持其他格式。
* @enum {number}
*/
export enum PixelFormat {
/**
+ * @en
* 16-bit texture without Alpha channel
+ * @zh
+ * 没有透明度通道的16位纹理
*/
RGB565 = GFXFormat.R5G6B5,
/**
+ * @en
* 16-bit textures: RGB5A1
+ * @zh
+ * 16位纹理:RGB5A1
*/
RGB5A1 = GFXFormat.RGB5A1,
/**
+ * @en
* 16-bit textures: RGBA4444
+ * @zh
+ * 16位纹理:RGBA4444
*/
RGBA4444 = GFXFormat.RGBA4,
/**
+ * @en
* 24-bit texture: RGB888
+ * @zh
+ * 24位纹理:RGB888
*/
RGB888 = GFXFormat.RGB8,
/**
+ * @en
* 32-bit texture: RGBA8888
+ * @zh
+ * 32位纹理:RGBA8888
*/
RGBA8888 = GFXFormat.RGBA8,
/**
+ * @en
* 32-bit float texture: RGBA32F
+ * @zh
+ * 32位纹理:RGBA32F
*/
RGBA32F = GFXFormat.RGBA32F,
/**
+ * @en
* 8-bit textures used as masks
+ * @zh
+ * 用作蒙版的8位纹理
*/
A8 = GFXFormat.A8,
/**
+ * @en
* 8-bit intensity texture
+ * @zh
+ * 8位强度纹理
*/
I8 = GFXFormat.L8,
/**
+ * @en
* 16-bit textures used as masks
+ * @zh
+ * 用作蒙版的16位纹理
*/
AI8 = GFXFormat.LA8,
/**
@@ -74,40 +106,64 @@ export enum PixelFormat {
}
/**
+ * @en
* The texture wrap mode.
+ * @zh
+ * 纹理环绕方式
* @enum {number}
*/
export enum WrapMode {
/**
+ * @en
* Specifies that the repeat warp mode will be used.
+ * @zh
+ * 指定环绕模式:重复纹理图像
*/
REPEAT = GFXAddress.WRAP,
/**
+ * @en
* Specifies that the clamp to edge warp mode will be used.
+ * @zh
+ * 指定环绕模式:纹理边缘拉伸效果
*/
CLAMP_TO_EDGE = GFXAddress.CLAMP,
/**
+ * @en
* Specifies that the mirrored repeat warp mode will be used.
+ * @zh
+ * 指定环绕模式:以镜像模式重复纹理图像
*/
MIRRORED_REPEAT = GFXAddress.MIRROR,
/**
+ * @en
* Specifies that the clamp to border wrap mode will be used.
+ * @zh
+ * 指定环绕模式:超出纹理坐标部分以用户指定颜色填充
*/
CLAMP_TO_BORDER = GFXAddress.BORDER,
}
/**
+ * @en
* The texture filter mode
+ * @zh
+ * 纹理过滤模式
* @enum {number}
*/
export enum Filter {
NONE = GFXFilter.NONE,
/**
+ * @en
* Specifies linear filtering.
+ * @zh
+ * 线性过滤模式
*/
LINEAR = GFXFilter.LINEAR,
/**
+ * @en
* Specifies nearest filtering.
+ * @zh
+ * 临近过滤模式
*/
NEAREST = GFXFilter.POINT,
}
diff --git a/cocos/assets/asset.ts b/cocos/assets/asset.ts
index 9d42e8b911..9e849a40c3 100644
--- a/cocos/assets/asset.ts
+++ b/cocos/assets/asset.ts
@@ -25,16 +25,16 @@
****************************************************************************/
import { ccclass, property } from '../core/data/class-decorator';
+import { Event } from '../core/event';
+import { CallbacksInvoker } from '../core/event/callbacks-invoker';
+import { EventTarget } from '../core/event/event-target';
+import { applyMixins, IEventTarget } from '../core/event/event-target-factory';
+import { createMap } from '../core/utils/js-typed';
import { Node } from '../scene-graph';
import { RawAsset } from './raw-asset';
-import { IEventTarget, applyMixins } from '../core/event/event-target-factory';
-import { EventTarget } from '../core/event/event-target';
-import { createMap } from '../core/utils/js-typed';
-import { CallbacksInvoker } from '../core/event/callbacks-invoker';
-import { Event } from '../core/event';
/**
- * !#en
+ * @en
* Base class for handling assets used in Creator.
*
* You may want to override:
@@ -42,7 +42,7 @@ import { Event } from '../core/event';
* - getset functions of _nativeAsset
* - cc.Object._serialize
* - cc.Object._deserialize
- * !#zh
+ * @zh
* Creator 中的资源基类。
*
* 您可能需要重写:
@@ -56,29 +56,86 @@ import { Event } from '../core/event';
*/
@ccclass('cc.Asset')
export class Asset extends RawAsset implements IEventTarget {
- /**
- * IEventTarget implementations, they will be overwrote with the same implementation in EventTarget by applyMixins
- */
- public _callbackTable = createMap(true);
- public on(type: string, callback: Function, target?: Object | undefined): Function | undefined {
- return;
- }
- public off(type: string, callback?: Function | undefined, target?: Object | undefined): void {}
- public targetOff(keyOrTarget?: string | Object | undefined): void {}
- public once(type: string, callback: Function, target?: Object | undefined): Function | undefined {
- return;
- }
- public dispatchEvent(event: Event): void {}
- public hasEventListener(key: string, callback?: Function | undefined, target?: Object | undefined): boolean {
- return false;
- }
- public removeAll(keyOrTarget?: string | Object | undefined): void {}
- public emit(key: string, ...args: any[]): void {}
/**
- * !#en
+ * @en Indicates whether its dependent raw assets can support deferred load if the owner scene (or prefab) is marked as `asyncLoadAssets`.
+ * @zh 当场景或 Prefab 被标记为 `asyncLoadAssets`,禁止延迟加载该资源所依赖的其它 RawAsset。
+ *
+ * @property {Boolean} preventDeferredLoadDependents
+ * @default false
+ * @static
+ */
+ public static preventDeferredLoadDependents = false;
+
+ /**
+ * @en Indicates whether its native object should be preloaded from native url.
+ * @zh 禁止预加载原生对象。
+ *
+ * @property {Boolean} preventPreloadNativeObject
+ * @default false
+ * @static
+ */
+ public static preventPreloadNativeObject = false;
+
+ /**
+ * 应 AssetDB 要求提供这个方法
+ * @method deserialize
+ * @param {String} data
+ * @return {Asset}
+ */
+ public static deserialize (data) {
+ return cc.deserialize(data);
+ }
+
+ /**
+ * @en
+ * Whether the asset is loaded or not
+ * @zh
+ * 该资源是否已经成功加载
+ */
+ public loaded = true;
+
+ /**
+ * @en
+ * Serializable url for native asset. For internal usage.
+ * @zh
+ * 用于本机资产的可序列化URL。供内部使用。
+ * @default ""
+ */
+ @property
+ public _native: string | undefined = '';
+
+ constructor (...args: ConstructorParameters) {
+ super(...args);
+ }
+
+ /**
+ * @en
+ * IEventTarget implementations, they will be overwrote with the same implementation in EventTarget by applyMixins
+ * @zh
+ * IEventTarget 实现,它们将被 applyMixins 在 EventTarget 中用相同的实现覆盖
+ */
+ // tslint:disable-next-line: member-ordering
+ public _callbackTable = createMap(true);
+ public on (type: string, callback: Function, target?: Object | undefined): Function | undefined {
+ return;
+ }
+ public off (type: string, callback?: Function | undefined, target?: Object | undefined): void {}
+ public targetOff (keyOrTarget?: string | Object | undefined): void {}
+ public once (type: string, callback: Function, target?: Object | undefined): Function | undefined {
+ return;
+ }
+ public dispatchEvent (event: Event): void {}
+ public hasEventListener (key: string, callback?: Function | undefined, target?: Object | undefined): boolean {
+ return false;
+ }
+ public removeAll (keyOrTarget?: string | Object | undefined): void {}
+ public emit (key: string, ...args: any[]): void {}
+
+ /**
+ * @en
* Returns the url of this asset's native object, if none it will returns an empty string.
- * !#zh
+ * @zh
* 返回该资源对应的目标平台资源的 URL,如果没有将返回一个空字符串。
* @property nativeUrl
* @type {String}
@@ -114,9 +171,13 @@ export class Asset extends RawAsset implements IEventTarget {
}
/**
- * The underlying native asset of this asset if one is available.
- * This property can be used to access additional details or functionality releated to the asset.
+ * @en
+ * The underlying native asset of this asset if one is available.
+ * This property can be used to access additional details or functionality releated to the asset.
* This property will be initialized by the loader if `_native` is available.
+ * @zh
+ * 此资源的基础资源(如果有)。 此属性可用于访问与资源相关的其他详细信息或功能。
+ * 如果`_native`可用,则此属性将由加载器初始化。
* @property {Object} _nativeAsset
* @default null
* @private
@@ -130,67 +191,24 @@ export class Asset extends RawAsset implements IEventTarget {
}
/**
- * !#en Indicates whether its dependent raw assets can support deferred load if the owner scene (or prefab) is marked as `asyncLoadAssets`.
- * !#zh 当场景或 Prefab 被标记为 `asyncLoadAssets`,禁止延迟加载该资源所依赖的其它 RawAsset。
- *
- * @property {Boolean} preventDeferredLoadDependents
- * @default false
- * @static
- */
- public static preventDeferredLoadDependents = false;
-
- /**
- * !#en Indicates whether its native object should be preloaded from native url.
- * !#zh 禁止预加载原生对象。
- *
- * @property {Boolean} preventPreloadNativeObject
- * @default false
- * @static
- */
- public static preventPreloadNativeObject = false;
-
- /**
- * 应 AssetDB 要求提供这个方法
- *
- * @method deserialize
- * @param {String} data
- * @return {Asset}
- * @static
- * @private
- */
- public static deserialize (data) {
- return cc.deserialize(data);
- }
- /**
- * !#en
- * Whether the asset is loaded or not
- * !#zh
- * 该资源是否已经成功加载
- */
- public loaded = true;
-
- /**
- * Serializable url for native asset. For internal usage.
- * @default ""
- */
- @property
- public _native: string | undefined = '';
-
- constructor (...args: ConstructorParameters) {
- super(...args);
- }
-
- /**
- * Returns the string representation of the object.
- *
- * The `Asset` object overrides the `toString()` method of the `Object` object.
- * JavaScript calls the toString() method automatically when an asset is to
- * be represented as a text value or when a texture is referred to in a string concatenation.
- *
- * For assets of the native type, it will return `this.nativeUrl`.
- * Otherwise, an empty string is returned.
+ * @en
+ * Returns the string representation of the object.
+ * The `Asset` object overrides the `toString()` method of the `Object` object.
+ * JavaScript calls the toString() method automatically
+ * when an asset is to be represented as a text value or when a texture is referred to in a string concatenation.
+ *
+ * For assets of the native type, it will return `this.nativeUrl`.
+ * Otherwise, an empty string is returned.
* This method may be overwritten by subclasses.
- *
+ * @zh
+ * 返回对象的字符串表示形式。
+ * `Asset` 对象将会重写 `Object` 对象的 `toString()` 方法。
+ * 当资源要表示为文本值时或在字符串连接时引用时,
+ * JavaScript 会自动调用 toString() 方法。
+ *
+ * 对于原始类型的资源,它将返回`this.nativeUrl`。
+ * 否则,返回空字符串。
+ * 子类可能会覆盖此方法。
* @method toString
* @return {String}
*/
@@ -210,14 +228,17 @@ export class Asset extends RawAsset implements IEventTarget {
// }
/**
+ * @en
* Set native file name for this asset.
+ * @zh
+ * 为此资源设置原始文件名
* @seealso nativeUrl
*
* @param filename
- * @param [inLibrary=true]
+ * @param inLibrary
* @private
*/
- public _setRawAsset (filename: string, inLibrary?: boolean) {
+ public _setRawAsset (filename: string, inLibrary: boolean = true) {
if (inLibrary !== false) {
this._native = filename || undefined;
}
@@ -227,10 +248,10 @@ export class Asset extends RawAsset implements IEventTarget {
}
/**
- * !#en
+ * @en
* Create a new node using this asset in the scene.
* If this type of asset dont have its corresponding node type, this method should be null.
- * !#zh
+ * @zh
* 使用该资源在场景中创建一个新节点。
* 如果这类资源没有相应的节点类型,该方法应该是空的。
*/
diff --git a/cocos/assets/bitmap-font.ts b/cocos/assets/bitmap-font.ts
index a8b7865cb9..d6918e32f2 100644
--- a/cocos/assets/bitmap-font.ts
+++ b/cocos/assets/bitmap-font.ts
@@ -33,10 +33,8 @@ export interface IConfig {
}
/**
- * !#en Class for BitmapFont handling.
- * !#zh 位图字体资源类。
- * @class BitmapFont
- * @extends Font
+ * @en Class for BitmapFont handling.
+ * @zh 位图字体资源类。
*/
@ccclass('cc.BitmapFont')
export class BitmapFont extends Font {
diff --git a/cocos/assets/font.ts b/cocos/assets/font.ts
index 4fcfc274a8..f7587cbd8b 100644
--- a/cocos/assets/font.ts
+++ b/cocos/assets/font.ts
@@ -28,10 +28,8 @@ import {ccclass} from '../core/data/class-decorator';
import { Asset } from './asset';
/**
- * !#en Class for Font handling.
- * !#zh 字体资源类。
- * @class Font
- * @extends Asset
+ * @en Class for Font handling.
+ * @zh 字体资源类。
*/
@ccclass('cc.Font')
export class Font extends Asset {
diff --git a/cocos/assets/label-atlas.ts b/cocos/assets/label-atlas.ts
index c6b540c5ef..fe56f70b2f 100644
--- a/cocos/assets/label-atlas.ts
+++ b/cocos/assets/label-atlas.ts
@@ -30,10 +30,8 @@ import { BitmapFont } from './bitmap-font';
* @module cc
*/
/**
- * !#en Class for LabelAtlas handling.
- * !#zh 艺术数字字体资源类。
- * @class LabelAtlas
- * @extends BitmapFont
+ * @en Class for LabelAtlas handling.
+ * @zh 艺术数字字体资源类。
*
*/
@ccclass('cc.LabelAtlas')
diff --git a/cocos/assets/ttf-font.ts b/cocos/assets/ttf-font.ts
index db26b02e75..4b1ee56e61 100644
--- a/cocos/assets/ttf-font.ts
+++ b/cocos/assets/ttf-font.ts
@@ -31,11 +31,8 @@ import { Font } from './font';
* @module cc
*/
/**
- * !#en Class for TTFFont handling.
- * !#zh TTF 字体资源类。
- * @class TTFFont
- * @extends Font
- *
+ * @en Class for TTFFont handling.
+ * @zh TTF 字体资源类。
*/
@ccclass('cc.TTFFont')
export class TTFFont extends Font {