自动图集浏览器运行,加载下面的图片可以。后来发现打包后这样直接加载图片不对,然后改成
Textures是个ab包,使用的时候是加载AutoAtlas然后和图集一样去加载图片吗?这样用不了。
你们自动图集是怎么用的。
无视自动图集
微信调试工具调试,动态加载不出来图片,警告Textures不包含下面的那些图片。
你什么版本? 我1.9.x和2.x.x都是无视自动合图的, 3.x.x还没用过.
我觉得3.x.x也肯定没问题, 没道理会开倒车.
能看下你怎么动态使用的自动和图目录下的图片不,打包后能用的,直接浏览器运行我这边无视也能用
加载图片和加载其它资源使用的同样的代码
/**
* 获取本地图片
* @param bundleUrl 包名地址
* @param showLoading 显示加载中字样 默认false
*/
public getSpriteFrameRes(bundleUrl: string, showLoading: boolean = false) {
return this.getRes(bundleUrl, cc.SpriteFrame, showLoading);
}
/**
* 获取本地资源
* @param bundleUrl 包名地址
* @param type 类型
* @param showLoading 显示加载中字样 默认false
*/
public async getRes<T extends cc.Asset>(bundleUrl: string, type: { prototype: T }, showLoading: boolean = false): Promise<T> {
let { bundleName, url } = this.parseBundleUrl(bundleUrl);
let bundle = await this.getBundle(bundleName, showLoading);
if (bundle) {
let asset = bundle.get(url, <any>type);
if (!asset) {
asset = await (this._resPromiseMap[bundleUrl] || (this._resPromiseMap[bundleUrl] = new Promise<T>((resolve, reject) => {
showLoading && this._showLoading();
bundle.load(url, <any>type, null, (error, asset: T) => {
showLoading && this._hideLoading();
error && console.error(`加载资源${bundleUrl}时出错:`);
error && console.error(error);
error ? resolve(null) : resolve(asset);
delete this._resPromiseMap[bundleUrl];
});
})));
}
return asset as T;
}
return null;
}
private _resPromiseMap: Record<string, Promise<cc.Asset>> = {};
有没有可能是你的url带了.png后缀?
找到原因了 自动图集下面的图片就不能用Texture加载了,用SpriteFrame就能找到了
3赞
原来如此.
合图后texture变成同一个了.
该主题在最后一个回复创建后14天后自动关闭。不再允许新的回复。