mirror of
https://gitee.com/dgflash/oops-plugin-framework.git
synced 2026-05-07 01:01:09 +08:00
框架内加载替换为oops.res.loadAsync
This commit is contained in:
@@ -17,14 +17,11 @@ export class ZipLoader {
|
||||
* @returns
|
||||
*/
|
||||
static load(url: string): Promise<JSZip> {
|
||||
return new Promise((resolve, reject) => {
|
||||
resLoader.load(url, BufferAsset, async (error: Error | null, asset: BufferAsset) => {
|
||||
if (error) return reject(error);
|
||||
|
||||
var zip = await JSZip.loadAsync(asset.buffer());
|
||||
this.zips.set(url, zip);
|
||||
resolve(zip);
|
||||
})
|
||||
return new Promise(async (resolve, reject) => {
|
||||
let asset = await resLoader.loadAsync(url, BufferAsset);
|
||||
var zip = await JSZip.loadAsync(asset.buffer());
|
||||
this.zips.set(url, zip);
|
||||
resolve(zip);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* @LastEditTime: 2022-04-08 15:42:16
|
||||
*/
|
||||
|
||||
import { Component, sp, _decorator } from 'cc';
|
||||
import { _decorator, Component, sp } from 'cc';
|
||||
import { oops } from '../../../core/Oops';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@@ -28,21 +28,21 @@ export class SpineFinishedRelease extends Component {
|
||||
this.spine.setCompleteListener(this.onSpineComplete.bind(this));
|
||||
|
||||
if (this.resPath) {
|
||||
oops.res.load(this.resPath, sp.SkeletonData, (err: Error | null, sd: sp.SkeletonData) => {
|
||||
if (err) {
|
||||
console.error(`加载【${this.resPath}】的 SPINE 资源不存在`);
|
||||
return;
|
||||
}
|
||||
|
||||
this.spine.skeletonData = sd;
|
||||
this.spine.setAnimation(0, "animation", false);
|
||||
});
|
||||
this.loadSkeletonData();
|
||||
}
|
||||
else {
|
||||
this.spine.setAnimation(0, "animation", false);
|
||||
}
|
||||
}
|
||||
|
||||
private async loadSkeletonData() {
|
||||
let sd = await oops.res.loadAsync(this.resPath, sp.SkeletonData);
|
||||
if (sd) {
|
||||
this.spine.skeletonData = sd;
|
||||
this.spine.setAnimation(0, "animation", false);
|
||||
}
|
||||
}
|
||||
|
||||
private onSpineComplete() {
|
||||
if (this.isDestroy) {
|
||||
this.node.destroy();
|
||||
|
||||
@@ -83,11 +83,12 @@ export class LanguagePack {
|
||||
return;
|
||||
}
|
||||
|
||||
resLoader.load(path, TTFFont, (err: Error | null, font: TTFFont) => {
|
||||
if (err == null) Logger.instance.logConfig(path, "下载语言包 ttf 资源");
|
||||
const font = await resLoader.loadAsync(path, TTFFont);
|
||||
if (font) {
|
||||
LanguageData.font = font;
|
||||
resolve();
|
||||
});
|
||||
Logger.instance.logConfig(path, "下载语言包 ttf 资源");
|
||||
}
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user