| 12345678910111213141516171819202122232425262728293031323334353637383940 |
- export default class PrefabUtil
- {
- private static objs={};
- //加载预制体
- public static load(call)
- {
- cc.resources.loadDir("./prefab/", (err, assets : cc.Prefab[])=>{
-
- if(assets!=null)
- {
- for(let i=0;i<assets.length;i++)
- {
- this.objs[assets[i].name]=assets[i];
- }
- call();
- }
-
- })
-
-
-
- }
- public static get(name:string):cc.Prefab
- {
- if(this.objs.hasOwnProperty(name)==false)
- {
- // console.error("没有找到预制体---"+name);
- }
- return this.objs[name];
- }
- }
|