加载预制

This commit is contained in:
2025-05-12 22:06:04 +08:00
parent 2ca60b215b
commit 941dd170b5
10 changed files with 23405 additions and 23390 deletions

7
src/constants/respath.ts Normal file
View File

@@ -0,0 +1,7 @@
export const respath = {
home_ui_res: "resources/Home.lh",
stage_ui_res: "resources/Stage.lh",
}

View File

@@ -0,0 +1,3 @@
{
"uuid": "1efa1426-84f2-4cc2-9061-6e7508539831"
}

View File

@@ -1,26 +1,36 @@
import { respath } from "../constants/respath"
import { Home } from "../views/Home"
import { Stage } from "../views/Stage"
const { regClass, property } = Laya
@regClass()
export class UIManager extends Laya.Script {
@property(Stage)
public stage: Stage
declare owner: Laya.Scene
private static _instance: UIManager
onAwake(): void {
UIManager._instance = this
this.stage.owner.visible = false
this.loadHome()
}
public static getInstance(): UIManager {
return UIManager._instance
}
public loadHome(): void {
Laya.loader.load(respath.home_ui_res).then((go)=>{
var prefab = go.create()
this.owner.addChild(prefab)
})
}
public loadStage(): void {
this.stage.owner.visible = true
this.stage.onLoadStage("aBCeIGFhdEDFcAHBGIhigBdfecAgHDiFBCaeBEAGHCIdffcIdEAHbgcABfGEdiHIFHaCDGEBDGEHbiaFC");
Laya.loader.load(respath.stage_ui_res).then((go)=>{
var prefab = go.create()
var stage = this.owner.addChild(prefab).getComponent(Stage)
stage.onLoadStage("aBCeIGFhdEDFcAHBGIhigBdfecAgHDiFBCaeBEAGHCIdffcIdEAHbgcABfGEdiHIFHaCDGEBDGEHbiaFC");
})
}
}

View File

@@ -15,6 +15,7 @@ export class Home extends Laya.Script {
console.log("btn_start=", evt);
this.owner.visible = false;
UIManager.getInstance().loadStage();
this.owner.destroy()
})
}