import { EResType, ResBaseAsset } from "./ResBaseAsset";

const { ccclass, menu, disallowMultiple, requireComponent } = cc._decorator;

/**
 * spine组件，自动管理资源的引用计数
 */
@ccclass
@disallowMultiple
@menu('UI/ResPrefab')
export default class ResPrefab extends ResBaseAsset<cc.Prefab> {

	protected readonly ResType: EResType = EResType.Prefab;
	/**
	 * @param bundle 
	 * @param url 
	 * @returns 
	 */
	loadPrefab(bundle: string, url: string, cb?: (asset: cc.Prefab) => void) {
		this.loadAsset(bundle, url, cc.Prefab, (asset: cc.Prefab) => {
			if (asset) {
				cb && cb(asset);
			} else {
				console.warn(`加载 prefab 失败: ${bundle} ${url}`);
				cb && cb(null);
			}
		});
	}
}
