Exemplo n.º 1
0
    /// <summary>
    /// 给所列表中的配置文件编码
    /// </summary>
    /// <param name="decoders"></param>
    /// <returns></returns>
    public static void EncodeCfgs(Type[] decoders)
    {
        foreach (Type decoderType in decoders)
        {
            ICfgDecoder decoder = Activator.CreateInstance(decoderType) as ICfgDecoder;
            if (decoder == null)
            {
                Debug.LogError("decoder == null, type = " + decoderType);
                continue;
            }

            if (!decoder.Enable)
            {
                continue;
            }

            ICfgReader reader = ReadCfg(decoder.GetName());
            if (reader == null)
            {
                continue;
            }

            if (!decoder.Decode(reader))
            {
                continue;
            }

            Save(decoder);
        }
    }
Exemplo n.º 2
0
        public bool Decode(ICfgReader excel)
        {
            if (excel == null || excel.RowCount == 0 || excel.ColCount == 0)
            {
                m_curRowIndex = 0;
                Log("配置文件为空", LogLevel.Error, true);
                return(false);
            }

            List <TConfig> datas = new List <TConfig>((int)excel.RowCount);

            for (uint i = 0; i < excel.RowCount; i++)
            {
                m_curRowIndex = i;
                IRowReader rowReader = excel.GetRow(i);
                if (rowReader == null)
                {
                    Log("行数据为空", LogLevel.Error, true);
                    continue;
                }

                ProcessSource(rowReader, datas);
            }

            m_curRowIndex = 0;
            AfterProcess(datas);
            m_row = null;

#if ServerClient
            m_data = new TConfigData();
#else
            m_data = UnityEngine.ScriptableObject.CreateInstance <TConfigData>();
#endif
            m_data.Data = datas.ToArray();
            return(true);
        }