yyl
2025-05-22 bde6d9006b4e708ef8a9ea7fc7efdaebe3db9ccd
Main/Config/ConfigBase.cs
@@ -1,12 +1,15 @@
using System.Collections.Generic;
using UnityEngine;
using Cysharp.Threading.Tasks;
using System.IO;
using System;
public class ConfigBase<U, T> where T : ConfigBase<U, T>, new()
{
    public static Dictionary<U, T> dic = new Dictionary<U, T>();
    protected static bool isInit = false;
    public static bool isInit = false;
    public static T Get(U id)
    {
@@ -49,6 +52,8 @@
    public static void Init(string[] lines)
    {
        dic.Clear();
        Dictionary<string, string> rawDatas = new Dictionary<string, string>();
        for (int i = 3; i < lines.Length; i++)
@@ -64,7 +69,19 @@
            T config = new T();
            U key = config.LoadKey(strKey);
            config.LoadConfig(line);
            #if UNITY_EDITOR
            try
            {
            #endif
            dic.Add(key, config);
            #if UNITY_EDITOR
            }
            catch (ArgumentException exception)
            {
                Debug.LogError(typeof(T).Name  + " 重复的key " + key + " " + exception.Message);
            }
            #endif
        }
        isInit = true;
@@ -134,7 +151,7 @@
        }
        else
        {
            Debug.LogError("GetKey 类型错误");
            Debug.LogError("GetKey 意外的key类型 类型错误 " + typeof(U).Name);
            return default(U);
        }
    }