MyApp.ts 1.1 KB

12345678910111213141516171819202122232425262728293031
  1. import { _decorator, Component } from 'cc';
  2. import { resMgr } from '../Frames/ResourcesMgr';
  3. import { dataMgr } from '../Frames/DataManager';
  4. import { LoadingUI } from './UI/LoadingUI';
  5. const { ccclass, property } = _decorator;
  6. @ccclass('MyApp')
  7. export class MyApp extends Component {
  8. protected async start(){
  9. // await UIMgr.openUI("LoadingUI",UIType.PAGE);
  10. // const loadingUI = UIMgr.getUI(LoadingUI);
  11. const loadingUI = this.node.getChildByName("LoadingUI").getComponent(LoadingUI)
  12. await dataMgr.loadDataDir("Data");
  13. await resMgr.loadAllRes("Res", (finish, total)=>{
  14. if(loadingUI){
  15. loadingUI.updateProgress(finish / total);
  16. loadingUI.updateWhichRes(1);
  17. }
  18. });
  19. await resMgr.loadAllRes("UI", (finish, total)=>{
  20. if(loadingUI){
  21. loadingUI.updateProgress(finish / total);
  22. loadingUI.updateWhichRes(2);
  23. }
  24. });
  25. this.node.getChildByName("LoadingUI").active = false;
  26. // UIMgr.closeUI("LoadingUI");
  27. // UIMgr.openUI("Start",UIType.PAGE);
  28. }
  29. }