From dcfb6d9951502c3a215c1a732f9241850e42e3b1 Mon Sep 17 00:00:00 2001 From: AZhan Date: Tue, 16 Nov 2021 18:47:47 +0800 Subject: [PATCH] Fix: the bug that inputmanager cannot be obtained (#589) * fix: the bug that inputmanager cannot be obtained --- packages/core/src/Engine.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/packages/core/src/Engine.ts b/packages/core/src/Engine.ts index f4224dc001..e6925f881e 100644 --- a/packages/core/src/Engine.ts +++ b/packages/core/src/Engine.ts @@ -48,6 +48,7 @@ export class Engine extends EventDispatcher { /** Physics manager of Engine. */ readonly physicsManager: PhysicsManager; + readonly inputManager: InputManager; _componentsManager: ComponentsManager = new ComponentsManager(); _hardwareRenderer: IHardwareRenderer; @@ -72,8 +73,6 @@ export class Engine extends EventDispatcher { /** @internal */ _spriteMaskManager: SpriteMaskManager; /** @internal */ - _inputManager: InputManager; - /** @internal */ _macroCollection: ShaderMacroCollection = new ShaderMacroCollection(); protected _canvas: Canvas; @@ -196,7 +195,7 @@ export class Engine extends EventDispatcher { this._spriteDefaultMaterial = this._createSpriteMaterial(); this._spriteMaskDefaultMaterial = this._createSpriteMaskMaterial(); - this._inputManager = new InputManager(this); + this.inputManager = new InputManager(this); const whitePixel = new Uint8Array([255, 255, 255, 255]); @@ -278,7 +277,7 @@ export class Engine extends EventDispatcher { this.physicsManager._update(deltaTime / 1000.0); componentsManager.callColliderOnLateUpdate(); } - this._inputManager._update(); + this.inputManager._update(); componentsManager.callScriptOnUpdate(deltaTime); componentsManager.callAnimationUpdate(deltaTime); componentsManager.callScriptOnLateUpdate(deltaTime); @@ -308,7 +307,7 @@ export class Engine extends EventDispatcher { if (this._sceneManager) { this._whiteTexture2D.destroy(true); this._whiteTextureCube.destroy(true); - this._inputManager._destroy(); + this.inputManager._destroy(); this.trigger(new Event("shutdown", this)); engineFeatureManager.callFeatureMethod(this, "shutdown", [this]);