예제 #1
0
        private static void PrepareForLoad <T>(string text)
        {
            TableTool.LoadData();

            //	找到记录的数据	//
            int i    = 0;
            var name = typeof(T).Name;

            for (i = 0; i < _tableDatas.TableDatas.Count; i++)
            {
                if (_tableDatas.TableDatas[i].ClassName.Equals(name))
                {
                    _tableData = _tableDatas.TableDatas[i];
                    break;
                }
            }

            if (_tableData == null)
            {
                throw new System.Exception("Can't find Excel File for " + name);
            }

            _lines = text.SplitLine();

            //	筛选要读的列	//
            string[] locate = _lines[PARAM_LOCATE].SplitStringByTab();
            _needRead = new List <int>();
            for (i = 0; i < locate.Length; i++)
            {
                if (locate[i].ToLower().Contains(CLIENT_MARK))
                {
                    _needRead.Add(i);
                }
            }
        }
예제 #2
0
        private void LoadCompleted(UnityEngine.Object obj)
        {
            var text = (obj as TextAsset).text;

            Result = TableTool.LoadDictionary <TK, T>(text);
            IsDone = true;
            Completed?.Invoke(this);
        }
예제 #3
0
        private void LoadCompleted(UnityEngine.Object obj)
        {
            var text = (obj as TextAsset).text;

            Result = TableTool.LoadTable <T>(text);
            IsDone = true;
            Completed?.Invoke(this);
            //Addressables.ReleaseAsset(obj.Result);
        }
예제 #4
0
        private void CheckData(int index, TableToolDatas.TableToolsData tableData)
        {
            string path = tableData.ClassPath;

            tableData.Cs    = AssetDatabase.LoadAssetAtPath <TextAsset>(path);
            tableData.Table = AssetDatabase.LoadAssetAtPath <TextAsset>(tableData.TablePath);

            if (tableData.Cs == null)
            {
                Debug.Log(string.Format("INDEX[{0}] 表[{1}] 的cs文件不存在", index, tableData.ClassName));
                return;
            }

            if (tableData.Table == null)
            {
                Debug.Log(string.Format("INDEX[{0}] 表[{1}] 的数值文件不存在,或不在Resources目录下", index, tableData.ClassName));
                return;
            }

            var _lines = tableData.Table.text.SplitLine();

            string[] locate    = _lines[TableTool.PARAM_LOCATE].SplitStringByTab();
            var      _needRead = new List <int>();

            for (int i = 0; i < locate.Length; i++)
            {
                if (locate[i].ToLower().Contains(TableTool.CLIENT_MARK))
                {
                    _needRead.Add(i);
                }
            }

            if (tableData.ConstructorTypes == null || tableData.ConstructorTypes.Count != _needRead.Count)
            {
                Debug.Log(string.Format("INDEX[{0}] 表[{1}] 的表结构有所更改,需要重新生成", index, tableData.ClassName));
            }


            for (int i = TableTool.PARAM_COUNT; i < _lines.Length; i++)
            {
                var paramList = new object[_needRead.Count];

                string[] words = _lines[i].SplitStringByTab();
                for (int j = 0; j < _needRead.Count; j++)
                {
                    try
                    {
                        paramList[j] = TableTool.ParseExcelType(words[_needRead[j]], tableData.ConstructorTypes[j]);
                    }
                    catch
                    {
                        Debug.Log(string.Format("INDEX[{0}] 表[{1}] 行[{2}]列[{3}] 的数据有问题", index, tableData.ClassName, i, j));
                    }
                }
            }
        }