laya-coreui-es
Version:
laya核心库、ui库es版本,剔除了媒体、TTF等功能。基于 LayaAir-release_2.12.0 修改
99 lines (98 loc) • 2.39 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Component = void 0;
const Pool_1 = require("../utils/Pool");
const Utils_1 = require("../utils/Utils");
class Component {
constructor() {
this._id = Utils_1.Utils.getGID();
this._resetComp();
}
get id() {
return this._id;
}
get enabled() {
return this._enabled;
}
set enabled(value) {
if (this._enabled != value) {
this._enabled = value;
if (this.owner) {
if (value)
this.owner.activeInHierarchy && this._onEnable();
else
this.owner.activeInHierarchy && this._onDisable();
}
}
}
get isSingleton() {
return true;
}
get destroyed() {
return this._destroyed;
}
_isScript() {
return false;
}
_resetComp() {
this._indexInList = -1;
this._enabled = true;
this._awaked = false;
this.owner = null;
}
_getIndexInList() {
return this._indexInList;
}
_setIndexInList(index) {
this._indexInList = index;
}
_onAdded() {
}
_onAwake() {
}
_onEnable() {
}
_onDisable() {
}
_onDestroy() {
}
onReset() {
}
_parse(data, interactMap = null) {
}
_parseInteractive(data = null, spriteMap = null) {
}
_cloneTo(dest) {
}
_setActive(value) {
if (value) {
if (!this._awaked) {
this._awaked = true;
this._onAwake();
}
this._enabled && this._onEnable();
}
else {
this._enabled && this._onDisable();
}
}
destroy() {
if (this.owner)
this.owner._destroyComponent(this);
}
_destroy() {
if (this.owner.activeInHierarchy && this._enabled)
this._setActive(false);
this._onDestroy();
this._destroyed = true;
if (this.onReset !== Component.prototype.onReset) {
this.onReset();
this._resetComp();
Pool_1.Pool.recoverByClass(this);
}
else {
this._resetComp();
}
}
}
exports.Component = Component;