mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-01 15:52:40 +08:00
Merge pull request #2524 from jareguo/master
not support loading sprite frame in atlas via loadRes
This commit is contained in:
@@ -1751,6 +1751,10 @@ Load image ( %s ) failed
|
||||
|
||||
Download Uuid: can not find type of raw asset[ %s ]: %s
|
||||
|
||||
### 4932
|
||||
|
||||
Since v1.10, for any atlas ("%s") in the "resources" directory, it is not possible to find the contained SpriteFrames via `loadRes`, `getRes` or `releaseRes`. Load the SpriteAtlas first and then use `spriteAtlas.getSpriteFrame(name)` instead please.
|
||||
|
||||
### 5000
|
||||
|
||||
object already destroyed
|
||||
|
||||
@@ -58,12 +58,23 @@ proto.getUuid = function (path, type) {
|
||||
if (item) {
|
||||
if (Array.isArray(item)) {
|
||||
if (type) {
|
||||
for (var i = 0; i < item.length; i++) {
|
||||
var entry = item[i];
|
||||
for (let i = 0; i < item.length; i++) {
|
||||
let entry = item[i];
|
||||
if (cc.isChildClassOf(entry.type, type)) {
|
||||
return entry.uuid;
|
||||
}
|
||||
}
|
||||
// not found
|
||||
if (CC_DEBUG && cc.isChildClassOf(type, cc.SpriteFrame)) {
|
||||
for (let i = 0; i < item.length; i++) {
|
||||
let entry = item[i];
|
||||
if (cc.isChildClassOf(entry.type, cc.SpriteAtlas)) {
|
||||
// not support sprite frame in atlas
|
||||
cc.errorID(4932, path);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
return item[0].uuid;
|
||||
@@ -72,6 +83,10 @@ proto.getUuid = function (path, type) {
|
||||
else if (!type || cc.isChildClassOf(item.type, type)) {
|
||||
return item.uuid;
|
||||
}
|
||||
else if (CC_DEBUG && cc.isChildClassOf(type, cc.SpriteFrame) && cc.isChildClassOf(item.type, cc.SpriteAtlas)) {
|
||||
// not support sprite frame in atlas
|
||||
cc.errorID(4932, path);
|
||||
}
|
||||
}
|
||||
return '';
|
||||
};
|
||||
@@ -84,6 +99,7 @@ proto.getUuidArray = function (path, type, out_urls) {
|
||||
var path2uuid = this._pathToUuid;
|
||||
var uuids = [];
|
||||
var isChildClassOf = cc.isChildClassOf;
|
||||
var _foundAtlasUrl;
|
||||
for (var p in path2uuid) {
|
||||
if ((p.startsWith(path) && isMatchByWord(p, path)) || !path) {
|
||||
var item = path2uuid[p];
|
||||
@@ -96,6 +112,9 @@ proto.getUuidArray = function (path, type, out_urls) {
|
||||
out_urls.push(p);
|
||||
}
|
||||
}
|
||||
else if (CC_DEBUG && entry.type === cc.SpriteAtlas) {
|
||||
_foundAtlasUrl = p;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -105,9 +124,16 @@ proto.getUuidArray = function (path, type, out_urls) {
|
||||
out_urls.push(p);
|
||||
}
|
||||
}
|
||||
else if (CC_DEBUG && item.type === cc.SpriteAtlas) {
|
||||
_foundAtlasUrl = p;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (CC_DEBUG && uuids.length === 0 && _foundAtlasUrl && cc.isChildClassOf(type, cc.SpriteFrame)) {
|
||||
// not support sprite frame in atlas
|
||||
cc.errorID(4932, _foundAtlasUrl);
|
||||
}
|
||||
return uuids;
|
||||
};
|
||||
|
||||
|
||||
@@ -298,7 +298,6 @@ var AssetLibrary = {
|
||||
resources.reset();
|
||||
var rawAssets = options.rawAssets;
|
||||
if (rawAssets) {
|
||||
var RES_DIR = 'resources/';
|
||||
for (var mountPoint in rawAssets) {
|
||||
var assets = rawAssets[mountPoint];
|
||||
for (var uuid in assets) {
|
||||
@@ -312,20 +311,11 @@ var AssetLibrary = {
|
||||
}
|
||||
_uuidToRawAsset[uuid] = new RawAssetEntry(mountPoint + '/' + url, type);
|
||||
// init resources
|
||||
if (mountPoint === 'assets' && url.startsWith(RES_DIR)) {
|
||||
if (cc.isChildClassOf(type, Asset)) {
|
||||
var ext = cc.path.extname(url);
|
||||
if (ext) {
|
||||
// trim base dir and extname
|
||||
url = url.slice(RES_DIR.length, - ext.length);
|
||||
}
|
||||
else {
|
||||
// trim base dir
|
||||
url = url.slice(RES_DIR.length);
|
||||
}
|
||||
}
|
||||
else {
|
||||
url = url.slice(RES_DIR.length);
|
||||
if (mountPoint === 'assets') {
|
||||
var ext = cc.path.extname(url);
|
||||
if (ext) {
|
||||
// trim base dir and extname
|
||||
url = url.slice(0, - ext.length);
|
||||
}
|
||||
var isSubAsset = info[2] === 1;
|
||||
// register
|
||||
|
||||
Reference in New Issue
Block a user