Ver.0.3.0.33
This commit is contained in:
@@ -4,6 +4,9 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using AibisDream.Framework;
|
||||
using AibisDream.Utility;
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
#endif
|
||||
using UnityEngine;
|
||||
|
||||
namespace AibisDream.Kit
|
||||
@@ -11,10 +14,8 @@ namespace AibisDream.Kit
|
||||
public class ConfigUtil : SingletonBase<ConfigUtil>
|
||||
{
|
||||
private const string CharacterConfigPath = "/Config/character.csv";
|
||||
private const string BaseConfigPath = "/Config/base_config.csv";
|
||||
private const string SpriteGroupPath = "/Config/sprite_group.json";
|
||||
|
||||
private Dictionary<string, string> _baseConfigDic;
|
||||
|
||||
private Dictionary<string, Character> _characters;
|
||||
private Dictionary<string, SpriteGroupConfig> _spriteConfigDict;
|
||||
|
||||
@@ -23,34 +24,27 @@ namespace AibisDream.Kit
|
||||
/// </summary>
|
||||
private ConfigUtil()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
EditorApplication.playModeStateChanged += OnPlayModeStateChanged;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#if UNITY_EDITOR
|
||||
private void OnPlayModeStateChanged(PlayModeStateChange state)
|
||||
{
|
||||
OnSingletonInit();
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// 调用时初始化
|
||||
/// </summary>
|
||||
public override void OnSingletonInit()
|
||||
{
|
||||
InitBaseConfig();
|
||||
InitCharacterConfig();
|
||||
InitSpriteGroupConfig();
|
||||
}
|
||||
|
||||
private void InitBaseConfig()
|
||||
{
|
||||
var baseList = CsvUtil.Read(Application.streamingAssetsPath + BaseConfigPath);
|
||||
if (baseList.Count <= 0)
|
||||
{
|
||||
Debug.Log("基础配置不存在");
|
||||
}
|
||||
|
||||
// 基础配置只有key和value
|
||||
_baseConfigDic = new Dictionary<string, string>();
|
||||
foreach (var arr in baseList)
|
||||
{
|
||||
_baseConfigDic.Add(arr[0], arr[1]);
|
||||
}
|
||||
}
|
||||
|
||||
private void InitCharacterConfig()
|
||||
{
|
||||
var characterList = CsvUtil.ReadAsBean<Character>(Application.streamingAssetsPath + CharacterConfigPath);
|
||||
@@ -74,17 +68,6 @@ namespace AibisDream.Kit
|
||||
return _characters.TryGetValue(key, out character);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 按key获取基础配置
|
||||
/// </summary>
|
||||
/// <param name="key">key</param>
|
||||
/// <param name="value">配置项</param>
|
||||
/// <returns>是否能获取</returns>
|
||||
public bool TryGetBaseConfig(string key, out string value)
|
||||
{
|
||||
return _baseConfigDic.TryGetValue(key, out value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 保存SpriteGroupConfig
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user