RedBagProgressWidget.ts 902 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. import RedBagProgressNode from "./RedBagProgressNode";
  2. import { utils } from "./Utils";
  3. const { ccclass, property } = cc._decorator;
  4. @ccclass
  5. export default class RedBagProgressWidget extends cc.Component {
  6. _redBagProgressNode: RedBagProgressNode = null;
  7. _isInit: boolean = false;
  8. _data: any = null;
  9. onLoad() {
  10. this._redBagProgressNode = this.getComponentInChildren("RedBagProgressNode");
  11. this._redBagProgressNode.node.active = false;
  12. }
  13. onEnable() {
  14. utils.registerServerInitEvent(() => {
  15. this._initWidget();
  16. }, this);
  17. }
  18. init(data?: any) {
  19. this._data = data;
  20. }
  21. onDisable() {
  22. utils.unregisterServerInitEvent(this);
  23. }
  24. _initWidget() {
  25. this._redBagProgressNode._location = this._data ? this._data.location : "default";
  26. this._redBagProgressNode.node.active = true;
  27. }
  28. }