/****************************************************************** * Copyright(C) 2019 - 2020 Nx Studio * * 主界面 --- 预加载 * * ******************************************************************/ // 预加载Prefab队列 const PrefabQueue = [ "prefab/bag/wnd_bag", "prefab/partner/bag/wnd_partner", "prefab/popup/popup_item_tips", "prefab/popup/popup_skill_tips", "prefab/popup/popup_rewards", "prefab/popup/popup_level_up", // "prefab/partner/wnd_partner_info", // "prefab/partner/wnd_partner_reform", // "prefab/summon/wnd_summon", // "prefab/vip/wnd_vip", ]; cc.Class( { extends: cc.Component, properties: { }, // 加载 onLoad: function() { // 延迟开始 this.scheduleOnce( () => { this.loadPrefabs(); }, 1 ); }, // 预制加载 loadPrefabs: function() { const self = this; const queue = nx.dt.objClone( PrefabQueue ); const next = function() { // 结束 if( queue.length == 0 ) { self.loadDone(); return; } // 下一个 let fab = queue.shift(); nx.debug( "[PRELOAD]预加载:", fab ); nx.res.loadPrefab( fab, ( _err, _asset ) => { if( _err ) { nx.warn( "[PRELOAD]预加载失败:", fab ); } next(); }, true ); }; next(); }, // 结束 loadDone: function() { }, } );