Esempio n. 1
0
        public void UpdateLocalizationToSB()
        {
            int col   = 0;
            int row   = 0;
            var excel = CaomaoEditorHelper.ReadExcelRow(this.ExcelFilePath, ref col, ref row);

            if (excel == null)
            {
                Debug.LogError("No Excel:" + this.ExcelFilePath);
                return;
            }
            DataRow firstRow = excel[0];

            for (int c = 2; c < col; c++)
            {
                var lang = firstRow[c] as string;
                if (string.IsNullOrEmpty(lang))
                {
                    continue;
                }
                Debug.Log(lang);
                this.AddConfigName(lang);
            }
            this.InitSbData();
            if (this.allSbData.Count > 0)
            {
                //第一行,第一列是id,接下来是各国语言
                for (int r = 1; r < row; r++)
                {
                    var nextRow = excel[r];
                    var id      = nextRow[1].ToString();
                    if (string.IsNullOrEmpty(id))
                    {
                        continue;
                    }
                    for (int c = 2; c < col; c++)
                    {
                        var index = c - 2;
                        if (index < this.Config.Count)
                        {
                            var content = excel[r][c].ToString();
                            if (string.IsNullOrEmpty(content))
                            {
                                continue;
                            }
                            Debug.Log(content);
                            var lang = this.Config[index].Language;
                            LocalizationData data = null;
                            this.allSbData.TryGetValue(lang, out data);
                            if (data != null)
                            {
                                data.AddData(id.ToString(), content);
                            }
                        }
                    }
                }
                this.SaveLocalizationData();
            }
        }