Пример #1
0
    /// <summary>
    /// 加载数据表
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <param name="path">二进制路径</param>
    /// <returns></returns>
    public T LoadData <T>(string path) where T : ExcelBase
    {
        if (string.IsNullOrEmpty(path))
        {
            return(null);
        }

        if (m_AllExcelData.ContainsKey(path))
        {
            Debug.LogError("重复加载相同配置文件" + path);
            return(m_AllExcelData[path] as T);
        }

        T data = BinarySerializeOpt.BinaryDeserilize <T>(path);

#if UNITY_EDITOR
        if (data == null)
        {
            Debug.Log(path + "不存在,从xml加载数据了!");
            string xmlPath = path.Replace("Binary", "Xml").Replace(".bytes", ".xml");
            data = BinarySerializeOpt.XmlDeserialize <T>(xmlPath);
        }
#endif

        if (data != null)
        {
            data.Init();
        }

        m_AllExcelData.Add(path, data);

        return(data);
    }