| 12345678910111213141516171819202122232425262728 |
- import { _decorator, AssetManager, assetManager, Component, find, instantiate, Node, Prefab, sys } from 'cc';
- const { ccclass } = _decorator;
- @ccclass('MainScene')
- export class MainScene extends Component {
- protected onLoad(): void {
- let str = "pay";
- if (sys.isBrowser) {
- let index = location.href.indexOf("?");
- if(index > -1){
- str = location.href.slice(index + 1);
- }
- }
- this.loadPrefab("prefab/"+str);
- }
- private loadPrefab(path:string){
- assetManager.loadBundle(path, (err:any, bundle:AssetManager.Bundle)=>{
- if(err)return;
- bundle.load(path, Prefab, (err:any, pre:Prefab)=>{
- let new_node = instantiate(pre);
- new_node.setParent(find("Canvas"));
- })
- })
- }
- }
|