diff --git a/cocos/assets/CCAsset.js b/cocos/assets/CCAsset.js index c661073789..84b5213c74 100644 --- a/cocos/assets/CCAsset.js +++ b/cocos/assets/CCAsset.js @@ -163,12 +163,15 @@ export default class Asset extends RawAsset { static preventPreloadNativeObject = false; /** - * Returns the asset's url. + * Returns the string representation of the object. * * The `Asset` object overrides the `toString()` method of the `Object` object. - * For `Asset` objects, the toString() method returns a string representation of the 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. + * * @method toString * @return {String} */ diff --git a/cocos/assets/CCTextAsset.js b/cocos/assets/CCTextAsset.js index 3688232b01..defdb3f665 100644 --- a/cocos/assets/CCTextAsset.js +++ b/cocos/assets/CCTextAsset.js @@ -44,6 +44,14 @@ export default class TextAsset extends Asset { @property() text = ""; + /** + * Returns the text content of the asset. + * + * 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. + * + * @method toString + * @return {String} + */ toString () { return this.text; }