import { _decorator, Component, Node, Prefab } from 'cc'; const { ccclass, property, executionOrder } = _decorator; @ccclass('Factory') export abstract class Factory { @property(Prefab) protected prefab: Prefab; public init() {} public abstract create(parent: Node): T; } @ccclass('FactoryComponent') export abstract class FactoryComponent extends Component { @property(Prefab) protected prefab: Prefab; protected onLoad(): void { this.init(); } public init() {} public abstract create(parent: Node): T; }