* 开始场景,启动实体处理器等 * * 这个方法会启动场景。它将启动实体处理器等,并调用onStart方法。 * 在编辑器模式下,此方法还会执行所有延迟的组件生命周期回调。 * * This method starts the scene. It will start entity processors and call onStart. * In editor mode, this method also executes all deferred component lifecycle callbacks.
()
| 460 | * In editor mode, this method also executes all deferred component lifecycle callbacks. |
| 461 | */ |
| 462 | public begin() { |
| 463 | this._didSceneBegin = true; |
| 464 | |
| 465 | if (this._deferredComponentCallbacks.length > 0) { |
| 466 | for (const callback of this._deferredComponentCallbacks) { |
| 467 | try { |
| 468 | callback(); |
| 469 | } catch (error) { |
| 470 | this._logger.error('Error executing deferred component callback:', error); |
| 471 | } |
| 472 | } |
| 473 | this._deferredComponentCallbacks = []; |
| 474 | } |
| 475 | |
| 476 | this.onStart(); |
| 477 | } |
| 478 | |
| 479 | /** |
| 480 | * 结束场景,清除实体、实体处理器等 |