fb0ff5c4-33e0-49f8-a5e8-1f242addb311.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. "use strict";
  2. cc._RF.push(module, 'fb0ffXEM+BJ+KXoHyQq3bMR', 'Singleton');
  3. // Script/Framework/Utils/Singleton.ts
  4. "use strict";
  5. Object.defineProperty(exports, "__esModule", { value: true });
  6. exports.Singleton = void 0;
  7. /**
  8. * 单例类父类
  9. */
  10. var Singleton = /** @class */ (function () {
  11. function Singleton() {
  12. }
  13. Singleton.getInstance = function () {
  14. if (this.instance == null) {
  15. var Class = this;
  16. this.instance = new Class();
  17. }
  18. return this.instance;
  19. };
  20. Singleton.ins = function () {
  21. if (this.instance == null) {
  22. var Class = this;
  23. this.instance = new Class();
  24. }
  25. return this.instance;
  26. };
  27. Singleton.createInstance = function () {
  28. if (this.instance == null) {
  29. var Class = this;
  30. this.instance = new Class();
  31. this.instance.init();
  32. }
  33. };
  34. Singleton.destroyInstance = function () {
  35. if (this.instance != null) {
  36. this.instance.unInit();
  37. this.instance = null;
  38. }
  39. };
  40. Singleton.prototype.init = function () { };
  41. ; //资源初始化
  42. Singleton.prototype.unInit = function () { };
  43. ; //资源释放
  44. return Singleton;
  45. }());
  46. exports.Singleton = Singleton;
  47. cc._RF.pop();