|
@@ -1,4 +1,4 @@
|
|
|
-import { _decorator, Component, error, Node, sys, UITransform, Widget } from 'cc';
|
|
|
+import { _decorator, Component, error, EventKeyboard, Input, input, instantiate, KeyCode, Node, Prefab, sys, UITransform, Widget } from 'cc';
|
|
|
import { BundleName } from 'db://assets/script/Config/EnumCfg';
|
|
|
import { AudioManager } from 'db://assets/script/Manager/AudioMgr';
|
|
|
import { LayerMgr } from 'db://assets/script/Manager/LayerMgr';
|
|
@@ -21,6 +21,7 @@ export class page_start extends Component {
|
|
|
|
|
|
|
|
|
start() {
|
|
|
+ input.on(Input.EventType.KEY_DOWN, this.onEditToolPanelClick, this);
|
|
|
AudioManager.instance.playBgm("bgm");
|
|
|
Promise.resolve(
|
|
|
GDM.gamecfgMgr.loadData(),
|
|
@@ -109,5 +110,30 @@ export class page_start extends Component {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ private onEditToolPanelClick(event: EventKeyboard) {
|
|
|
+ switch (event.keyCode) {
|
|
|
+ case KeyCode.F2:
|
|
|
+ console.log("按下了F2")
|
|
|
+ LayerMgr.instance.loadBundle("editor", () => {
|
|
|
+ this.loadPrefab("prefab/SuperFindPanel", (prefab: Prefab) => {
|
|
|
+ let node = instantiate(prefab);
|
|
|
+ node.parent = this.node;
|
|
|
+ })
|
|
|
+ })
|
|
|
+
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ prefabMap: Map<string, Prefab> = new Map();
|
|
|
+ loadPrefab(path: string, callback: (prefab: Prefab) => void) {
|
|
|
+ if (this.prefabMap.has(path)) {
|
|
|
+ callback(this.prefabMap.get(path));
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ LayerMgr.instance.loadPrefab("editor", path, (prefab: Prefab) => {
|
|
|
+ this.prefabMap.set(path, prefab);
|
|
|
+ callback(prefab);
|
|
|
+ });
|
|
|
+ }
|
|
|
|
|
|
}
|