diff --git a/cocos2d/core/load-pipeline/CCLoader.js b/cocos2d/core/load-pipeline/CCLoader.js index 0608a322c6..e1691a56e5 100644 --- a/cocos2d/core/load-pipeline/CCLoader.js +++ b/cocos2d/core/load-pipeline/CCLoader.js @@ -45,7 +45,7 @@ function getResWithUrl (res) { if (typeof res === 'object') { result = res; if (res.url) { - return res.url; + return result; } else { id = res.uuid; @@ -199,7 +199,13 @@ JS.mixin(CCLoader.prototype, { _sharedResources.length = 0; for (var i = 0; i < resources.length; ++i) { - var res = getResWithUrl(resources[i]); + var resource = resources[i]; + // Backward compatibility + if (resource && resource.id) { + cc.warn('Sorry, you shouldn\'t use id as item identity any more, please use url or uuid instead, the current id is being set as url: ' + resource.id); + resource.url = resource.url || resource.id; + } + var res = getResWithUrl(resource); if (!res.url && !res.uuid) continue; var item = this.getItem(res.url); diff --git a/cocos2d/core/load-pipeline/pack-downloader.js b/cocos2d/core/load-pipeline/pack-downloader.js index 3b803080c3..4c78e50b19 100644 --- a/cocos2d/core/load-pipeline/pack-downloader.js +++ b/cocos2d/core/load-pipeline/pack-downloader.js @@ -142,7 +142,7 @@ module.exports = { * @returns {Boolean} specify whether loaded by pack */ load: function (item, callback) { - var uuid = item.id; + var uuid = item.uuid; var packUuid = uuidToPack[uuid]; if (!packUuid) { return false; diff --git a/cocos2d/core/platform/CCAssetLibrary.js b/cocos2d/core/platform/CCAssetLibrary.js index 2188882c92..e5f2346d29 100644 --- a/cocos2d/core/platform/CCAssetLibrary.js +++ b/cocos2d/core/platform/CCAssetLibrary.js @@ -88,7 +88,7 @@ var AssetLibrary = { Editor.error('Sorry, the scene data of "%s" is corrupted!', uuid); } else { - // We know scene is a raw asset, so we can pass uuid to this API directly + // We know scene is not a raw asset, so we can pass uuid to this API directly asset.scene.dependAssets = AutoReleaseUtils.getDependsRecursively(uuid); } } @@ -225,7 +225,7 @@ var AssetLibrary = { } else { if (asset.constructor === cc.SceneAsset) { - // We know scene is a raw asset, so we can pass uuid to this API directly + // We know scene is not a raw asset, so we can pass uuid to this API directly asset.scene.dependAssets = AutoReleaseUtils.getDependsRecursively(randomUuid); } if (CC_EDITOR || isScene(asset)) {