@engine.decorators.serialize("Demo")
export default class Demo extends engine.Script {
@engine.decorators.property({
type: engine.TypeNames.String
})
public name: string = "Demo";
public onAwake() {
engine.loader.load<engine.Prefab>("demo1.prefab").promise.then(pre => {
const grid = pre.instantiate();
grid.addComponent(Grid);
grid.addComponent(engine.TouchInputComponent)
this.entity.transform2D.addChild(grid.transform2D);
});
}
}
@engine.decorators.serialize("Grid")
export default class grid extends engine.Script {
@engine.decorators.property({
type: engine.TypeNames.String
})
public name: string = "Grid"
public onAwake() {
console.log("can_awake");
this.entity.addComponent(engine.TouchInputComponent);/* */
}
//触摸开始事件。
public onTouchStart(s: engine.TouchInputComponent, e: TouchInputEvent) {
this.touch_start = true;
console.log("can_grid_start");
}
}
在demo中加载了grid资源,然后队grid资源添加touch组件以及script组件。但是grid中的touch组件不生效。
这个原因是什么那?是因为prefab本身不能加载touch组件还是怎样?
或者有什么可以排查思路吗?