加载预制
This commit is contained in:
7
src/constants/respath.ts
Normal file
7
src/constants/respath.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
|
||||
|
||||
export const respath = {
|
||||
home_ui_res: "resources/Home.lh",
|
||||
stage_ui_res: "resources/Stage.lh",
|
||||
}
|
||||
|
||||
3
src/constants/respath.ts.meta
Normal file
3
src/constants/respath.ts.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"uuid": "1efa1426-84f2-4cc2-9061-6e7508539831"
|
||||
}
|
||||
@@ -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");
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user