大侠
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.
 
 
 

90 lines
2.7 KiB

import InstanceT from "../ExUtils/InstanceT";
/**
* 关键资源点名字枚举
*/
export enum EKeyResName {
/**预制体路径 */
HttpUrl = '',
/**CSV配置表目录 */
ConfigCsv = 'ConfigCsv',
/**Json配置表目录 */
ConfigJson = 'ConfigJson',
/**预制体 */
Prefabs = 'Prefabs',
/**UI预制体 */
UIPrefabs = 'UIPrefabs',
/**UI子预制体 */
UIChildPrefabs = 'UIChildPrefabs',
/**spine动画文件 */
Spine = 'Spine',
/**图片文件 */
Texture = 'Texture',
/**图集 */
Atlas = "Atlas",
/** 字体目录 */
Font = 'Font',
/** 音效文件目录 */
Sound = 'Sound',
/**视频 */
Video = 'Video',
}
/**
* 关键资源点列表管理器
*/
@InstanceT.DecorateInstance()
export default class KeyResManager {
/** 单例 */
private static readonly instance: KeyResManager;
//关键资源列表
private m_KeyResList: { [index: string]: string } = {};
//
private constructor() {
//注册关键资源目录
this.m_KeyResList = {
[EKeyResName.HttpUrl]: EKeyResName.HttpUrl + '/',
[EKeyResName.ConfigCsv]: EKeyResName.HttpUrl + EKeyResName.ConfigCsv + '/',
[EKeyResName.ConfigJson]: EKeyResName.HttpUrl + EKeyResName.ConfigJson + '/',
[EKeyResName.Prefabs]: EKeyResName.HttpUrl + EKeyResName.Prefabs + '/',
[EKeyResName.UIPrefabs]: EKeyResName.HttpUrl + EKeyResName.UIPrefabs + '/',
[EKeyResName.UIChildPrefabs]: EKeyResName.HttpUrl + EKeyResName.UIChildPrefabs + '/',
[EKeyResName.Spine]: EKeyResName.HttpUrl + EKeyResName.Spine + '/',
[EKeyResName.Texture]: EKeyResName.HttpUrl + EKeyResName.Texture + '/',
[EKeyResName.Atlas]: EKeyResName.HttpUrl + EKeyResName.Atlas + '/',
[EKeyResName.Sound]: EKeyResName.HttpUrl + EKeyResName.Sound + "/",
[EKeyResName.Font]: EKeyResName.HttpUrl + EKeyResName.Font + '/',
[EKeyResName.Video]: EKeyResName.HttpUrl + EKeyResName.Video + "/",
};
};
/**
* 判断是否存在某个关键点key
* @param _key 关键点key
*/
public static ifKeyRes(_key: string): boolean {
return Object.keys(this.instance.m_KeyResList).findIndex((item) => {
return item == _key;
}) != -1;
}
/**
* 获取一个关键点资源的路径
* @param _key 关键点key
*/
public static getResURL(_key: string): string {
return this.instance.m_KeyResList[_key];
}
/**
* 动态添加关键路径
* @param _key 关键值
* @param _string 路径
*/
public static addResUrl(_key: string, _string: string) {
this.instance.m_KeyResList[_key] = _string;
}
}