我智商爆棚
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
1.6 KiB

4 weeks ago
/*
* @Descripttion:
* @version: 1.0.0
* @Author: YeeChan
* @Date: 2020-07-23 16:59:58
*/
/**
*
* cc.Asset 1
*/
export default class RemoteMgr {
private static remoteArrayTexture_custom: { [key: string]: cc.Texture2D; } = {}
/**
*
*/
public static removeAllRemote_custom() {
for (let k in this.remoteArrayTexture_custom) {
this.remoteArrayTexture_custom[k].decRef();
}
this.remoteArrayTexture_custom = {};
}
/**
* ,
* @param url
* @param listener
*/
public static loadRemote_custom(url: string, listener: FMListener) {
let texture2D = this.remoteArrayTexture_custom[url];
if (texture2D) {
callFM_custom(listener, null, this.remoteArrayTexture_custom[url]);
} else {
cc.assetManager.loadRemote(url, (error, data) => {
if (error) {
callFM_custom(listener, error, null);
return;
} else {
if (!this.remoteArrayTexture_custom[url]) {
//@ts-ignore
this.remoteArrayTexture_custom[url] = data;
this.remoteArrayTexture_custom[url].addRef();//计数+1
}
callFM_custom(listener, null, this.remoteArrayTexture_custom[url]);
}
})
}
}
}