getDependsRecursively的api有错误

深坑,非专业人士估计一时半会看不懂,希望cocos开发者注意一下。

getDependsRecursively这个api的描述是:获取一个指定资源的所有依赖资源,包含它自身,并保存在数组中返回。owner 参数接收以下几种类型:1. 资源 asset 对象;2. 资源目录下的 url;3. 资源的 uuid。

但是事实上,只有传1. 资源 asset 对象;是可以得到完整的depends的列表的

因为传url或者uuid,会调用
var key = this._getReferenceKey(owner);
var assets = AutoReleaseUtils.getDependsRecursively(key);
assets.push(key);
return assets;

这里的key是uuid
而到了 AutoReleaseUtils.getDependsRecursively(key)这里
会调用cc.loader.getItem(key);
而cc.loader.getItem(key)这里,会直接返回 item = this._cache[id];
而cc.loader._cache里面的索引,根本不是uuid,而是资源的路径
所以item一定为空,
所以getDependsRecursively一定只返回一个uuid

1赞

这个可能是老版本的 bug,不记得什么时候修好了…… 可能是 1.9 或 1.10。目前结果是对的

补充,该 API 只能传入加载后的资源的 uuid。加载前是不知道依赖的。
https://github.com/cocos-creator/engine/pull/3548

是否可以确定,在1.9还是1.10 ,或者最新版本也是ok的?