LoadingUI.ts 921 B

123456789101112131415161718192021222324252627282930
  1. import { _decorator,Label, ProgressBar } from 'cc';
  2. import { UIBase } from '../GameFrameWork/UIBase';
  3. const { ccclass, property } = _decorator;
  4. @ccclass('LoadingUI')
  5. export class LoadingUI extends UIBase {
  6. progressBar: ProgressBar = null;
  7. progressLabel: Label = null;
  8. whichRes: Label = null;
  9. protected onStart(): void {
  10. this.progressBar = this.getComponentInChildren(ProgressBar);
  11. this.progressLabel = this.getComponentInChildren(Label);
  12. this.whichRes = this.getLabel("_which");
  13. }
  14. public updateProgress(progress: number){
  15. if(this.progressBar){
  16. this.progressBar.progress = progress;
  17. }
  18. if(this.progressLabel){
  19. this.progressLabel.string = `${Math.floor(progress * 100)}%`;
  20. }
  21. }
  22. public updateWhichRes(which: number){
  23. if(this.whichRes){
  24. this.whichRes.string = `${which}/2`;
  25. }
  26. }
  27. }