public AssetConfig LoadConfig(Type configType, string location) { string configName = Path.GetFileName(location); // 防止重复加载 if (_configs.ContainsKey(configName)) { MotionLog.Error($"Config {configName} is already existed."); return(null); } AssetConfig config = Activator.CreateInstance(configType) as AssetConfig; if (config != null) { config.Load(location); _configs.Add(configName, config); } else { MotionLog.Error($"Config {configType.FullName} create instance failed."); } return(config); }
/// <summary> /// 加载配表 /// </summary> /// <param name="configName">配表文件名称</param> public AssetConfig LoadConfig(string configName) { // 防止重复加载 if (_configs.ContainsKey(configName)) { MotionLog.Log(ELogLevel.Error, $"Config {configName} is already existed."); return(null); } AssetConfig config = ConfigCreater.CreateInstance(configName); if (config != null) { string location = $"{_baseDirectory}/{configName}"; config.Load(location); _configs.Add(configName, config); } else { MotionLog.Log(ELogLevel.Error, $"Config type {configName} is invalid."); } return(config); }
/// <summary> /// 加载配表 /// </summary> /// <param name="cfgName">配表文件名称</param> public void Load(string cfgName, System.Action <AssetConfig> callback) { // 防止重复加载 if (_cfgs.ContainsKey(cfgName)) { LogSystem.Log(ELogType.Error, $"Config {cfgName} is already exist."); return; } AssetConfig config = ConfigHandler.Handle(cfgName); if (config != null) { string location = BaseFolderPath + cfgName; _cfgs.Add(cfgName, config); config.Init(location); config.Load(callback); } else { LogSystem.Log(ELogType.Error, $"Config {cfgName} calss is invalid."); } }