This commit is contained in:
2024-04-16 23:03:54 +08:00
commit 54580cc1b2
723 changed files with 103745 additions and 0 deletions

View File

@@ -0,0 +1,30 @@
import { AssetManager, Prefab, _decorator } from 'cc'
const { ccclass, property } = _decorator
import { Logger } from './Logger'
@ccclass('PrefabLoader')
export default class PrefabLoader {
private static isLoading: boolean = false
public static loadPrefab(url: string, callback: Function) {
if (this.isLoading) return
this.isLoading = true
AssetManager.instance.resources.load(
url,
Prefab,
(error: Error, loadedResource) => {
if (error) {
Logger.warn(this, '载入Prefab失败, 原因:', url, error.message)
return
}
if (!(loadedResource instanceof Prefab)) {
Logger.warn(this, '你载入的不是Prefab, 你做了什么事?')
return
}
callback(loadedResource)
this.isLoading = false
}
)
}
}