You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
59 lines
1.9 KiB
59 lines
1.9 KiB
import { Component, Scene, _decorator, director, sys,Node } from "cc";
|
|
import FileEnditor from "./Enditor/FileEnditor";
|
|
import FileBase from "./FileBase";
|
|
import FileJSB from "./JSB/FileJSB";
|
|
import FileWeb from "./web/FileWeb";
|
|
import { EDITOR, JSB } from "cc/env";
|
|
|
|
const { ccclass, property, playOnFocus, executeInEditMode ,executionOrder} = _decorator;
|
|
|
|
@ccclass
|
|
// @executeInEditMode
|
|
// @playOnFocus
|
|
// @executionOrder(-1)//必须优先执行 此脚本 否者其他脚本在onLoad中 调用单列会进行多次节点创建
|
|
export default class FileManager{
|
|
private static _instance: FileManager;
|
|
// protected onLoad(): void {
|
|
// FileManager._instance = this;
|
|
// FileManager._instance.Init();
|
|
// }
|
|
public static ins(): FileManager {
|
|
if (!this._instance) {
|
|
this._instance = new FileManager();// this.CreateFileManagerNode();
|
|
this._instance.Init();
|
|
}
|
|
return this._instance;
|
|
}
|
|
|
|
public static insFile(): FileBase {
|
|
return this.ins().mFileTools;
|
|
}
|
|
|
|
// static CreateFileManagerNode(): FileManager {
|
|
// let tNode: Node = null;
|
|
// var scene:Scene = director.getScene();
|
|
// if (EDITOR) {
|
|
// tNode = new Node("FileManager");
|
|
// scene.addChild(tNode);
|
|
// } else if (sys.isBrowser) {
|
|
// tNode = new Node("FileManager");
|
|
// scene.addChild(tNode);
|
|
// } else if (JSB) {
|
|
// tNode = new Node("FileManager");
|
|
// scene.addChild(tNode);
|
|
// }
|
|
// return tNode.addComponent(FileManager);
|
|
// }
|
|
|
|
mFileTools:FileBase;
|
|
private Init() {
|
|
if(EDITOR){
|
|
this.mFileTools = new FileEnditor();
|
|
}else if(sys.isBrowser){
|
|
this.mFileTools = new FileWeb();
|
|
}else if(JSB){
|
|
this.mFileTools = new FileJSB();
|
|
}
|
|
this.mFileTools.onLoad();
|
|
}
|
|
}
|
|
|