新增getComponentInScene
This commit is contained in:
6
source/bin/framework.d.ts
vendored
6
source/bin/framework.d.ts
vendored
@@ -364,6 +364,12 @@ declare module es {
|
|||||||
* @param type
|
* @param type
|
||||||
*/
|
*/
|
||||||
getComponent<T extends Component>(type: new (...args: any[]) => T): T;
|
getComponent<T extends Component>(type: new (...args: any[]) => T): T;
|
||||||
|
/**
|
||||||
|
* 获取类型T的第一个并已加入场景的组件并返回它。如果没有找到组件,则返回null。
|
||||||
|
* @param type
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
getComponentInScene<T extends Component>(type: new (...args: any[]) => T): T;
|
||||||
/**
|
/**
|
||||||
* 尝试获取T类型的组件。如果未找到任何组件,则返回false
|
* 尝试获取T类型的组件。如果未找到任何组件,则返回false
|
||||||
* @param type
|
* @param type
|
||||||
|
|||||||
@@ -941,6 +941,14 @@ var es;
|
|||||||
Entity.prototype.getComponent = function (type) {
|
Entity.prototype.getComponent = function (type) {
|
||||||
return this.components.getComponent(type, false);
|
return this.components.getComponent(type, false);
|
||||||
};
|
};
|
||||||
|
/**
|
||||||
|
* 获取类型T的第一个并已加入场景的组件并返回它。如果没有找到组件,则返回null。
|
||||||
|
* @param type
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
Entity.prototype.getComponentInScene = function (type) {
|
||||||
|
return this.components.getComponent(type, true);
|
||||||
|
};
|
||||||
/**
|
/**
|
||||||
* 尝试获取T类型的组件。如果未找到任何组件,则返回false
|
* 尝试获取T类型的组件。如果未找到任何组件,则返回false
|
||||||
* @param type
|
* @param type
|
||||||
@@ -4037,8 +4045,10 @@ var es;
|
|||||||
ComponentList.prototype.update = function () {
|
ComponentList.prototype.update = function () {
|
||||||
this.updateLists();
|
this.updateLists();
|
||||||
for (var i = 0; i < this._updatableComponents.length; i++) {
|
for (var i = 0; i < this._updatableComponents.length; i++) {
|
||||||
if (this._updatableComponents[i].enabled)
|
var component = this._updatableComponents[i];
|
||||||
this._updatableComponents[i].update();
|
if (component.enabled) {
|
||||||
|
component.update();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
ComponentList.prototype.onEntityTransformChanged = function (comp) {
|
ComponentList.prototype.onEntityTransformChanged = function (comp) {
|
||||||
|
|||||||
2
source/bin/framework.min.js
vendored
2
source/bin/framework.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -409,6 +409,15 @@ module es {
|
|||||||
return this.components.getComponent(type, false);
|
return this.components.getComponent(type, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取类型T的第一个并已加入场景的组件并返回它。如果没有找到组件,则返回null。
|
||||||
|
* @param type
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
public getComponentInScene<T extends Component>(type: new (...args) => T): T {
|
||||||
|
return this.components.getComponent(type, true);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 尝试获取T类型的组件。如果未找到任何组件,则返回false
|
* 尝试获取T类型的组件。如果未找到任何组件,则返回false
|
||||||
* @param type
|
* @param type
|
||||||
|
|||||||
Reference in New Issue
Block a user