从 tslib 导入辅助函数
This commit is contained in:
@@ -14,7 +14,6 @@ import { SceneSerializer, SceneSerializationOptions, SceneDeserializationOptions
|
||||
import { IncrementalSerializer, IncrementalSnapshot, IncrementalSerializationOptions } from './Serialization/IncrementalSerializer';
|
||||
import { ComponentPoolManager } from './Core/ComponentPool';
|
||||
import { PerformanceMonitor } from '../Utils/PerformanceMonitor';
|
||||
import { Core } from '../Core';
|
||||
import { ServiceContainer, type ServiceType } from '../Core/ServiceContainer';
|
||||
import { createInstance, isInjectable } from '../Core/DI';
|
||||
import { isUpdatable, getUpdatableMetadata } from '../Core/DI/Decorators';
|
||||
@@ -183,11 +182,9 @@ export class Scene implements IScene {
|
||||
this._services = new ServiceContainer();
|
||||
this.logger = createLogger('Scene');
|
||||
|
||||
if (config?.performanceMonitor) {
|
||||
this._performanceMonitor = config.performanceMonitor;
|
||||
} else {
|
||||
this._performanceMonitor = Core.services.resolve(PerformanceMonitor);
|
||||
}
|
||||
// 从配置获取 PerformanceMonitor,如果未提供则创建一个新实例
|
||||
// Scene 应该是独立的,不依赖于 Core,通过构造函数参数明确依赖关系
|
||||
this._performanceMonitor = config?.performanceMonitor || new PerformanceMonitor();
|
||||
|
||||
if (config?.name) {
|
||||
this.name = config.name;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { IScene } from './IScene';
|
||||
import { ECSFluentAPI, createECSAPI } from './Core/FluentAPI';
|
||||
import { Time } from '../Utils/Time';
|
||||
import { Core } from '../Core';
|
||||
import { createLogger } from '../Utils/Logger';
|
||||
import type { IService } from '../Core/ServiceContainer';
|
||||
|
||||
@@ -68,6 +67,21 @@ export class SceneManager implements IService {
|
||||
*/
|
||||
private _logger = createLogger('SceneManager');
|
||||
|
||||
/**
|
||||
* 场景切换回调函数
|
||||
*/
|
||||
private _onSceneChangedCallback?: () => void;
|
||||
|
||||
/**
|
||||
* 设置场景切换回调
|
||||
*
|
||||
* @param callback 场景切换时的回调函数
|
||||
* @internal
|
||||
*/
|
||||
public setSceneChangedCallback(callback: () => void): void {
|
||||
this._onSceneChangedCallback = callback;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置当前场景(立即切换)
|
||||
*
|
||||
@@ -104,10 +118,9 @@ export class SceneManager implements IService {
|
||||
// 触发场景切换回调
|
||||
Time.sceneChanged();
|
||||
|
||||
// 通知调试管理器
|
||||
const coreInstance = Core.Instance;
|
||||
if (coreInstance && coreInstance._debugManager) {
|
||||
coreInstance._debugManager.onSceneChanged();
|
||||
// 通知调试管理器(通过回调)
|
||||
if (this._onSceneChangedCallback) {
|
||||
this._onSceneChangedCallback();
|
||||
}
|
||||
|
||||
this._logger.info(`Scene changed to: ${scene.name}`);
|
||||
|
||||
Reference in New Issue
Block a user