mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-01 07:42:38 +08:00
remove canvas access warning in Editor (#11709)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { TEST } from 'internal:constants';
|
||||
import { EDITOR, TEST } from 'internal:constants';
|
||||
import { MouseCallback } from 'pal/input';
|
||||
import { systemInfo } from 'pal/system-info';
|
||||
import { screenAdapter } from 'pal/screen-adapter';
|
||||
@@ -25,14 +25,17 @@ export class MouseInputSource {
|
||||
constructor () {
|
||||
if (systemInfo.hasFeature(Feature.EVENT_MOUSE)) {
|
||||
this._canvas = document.getElementById('GameCanvas') as HTMLCanvasElement;
|
||||
if (!this._canvas && !TEST) {
|
||||
if (!this._canvas && !TEST && !EDITOR) {
|
||||
console.warn('failed to access canvas');
|
||||
}
|
||||
|
||||
this._handleMouseDown = this._createCallback(InputEventType.MOUSE_DOWN);
|
||||
this._handleMouseMove = this._createCallback(InputEventType.MOUSE_MOVE);
|
||||
this._handleMouseUp = this._createCallback(InputEventType.MOUSE_UP);
|
||||
this._registerEvent();
|
||||
// In Editor, we receive mouse event from manually event dispatching.
|
||||
if (!EDITOR) {
|
||||
this._registerEvent();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { TouchCallback } from 'pal/input';
|
||||
import { TEST } from 'internal:constants';
|
||||
import { EDITOR, TEST } from 'internal:constants';
|
||||
import { systemInfo } from 'pal/system-info';
|
||||
import { screenAdapter } from 'pal/screen-adapter';
|
||||
import { Rect, Vec2 } from '../../../cocos/core/math';
|
||||
@@ -17,10 +17,13 @@ export class TouchInputSource {
|
||||
constructor () {
|
||||
if (systemInfo.hasFeature(Feature.INPUT_TOUCH)) {
|
||||
this._canvas = document.getElementById('GameCanvas') as HTMLCanvasElement;
|
||||
if (!this._canvas && !TEST) {
|
||||
if (!this._canvas && !TEST && !EDITOR) {
|
||||
console.warn('failed to access canvas');
|
||||
}
|
||||
this._registerEvent();
|
||||
// In Editor, we don't receive touch event but maybe receive simulated touch event.
|
||||
if (!EDITOR) {
|
||||
this._registerEvent();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user