Пример #1
0
        private static void GetKeysFromPrefabs(SortedDictionary <string, LocalizationRecord> storage)
        {
            var allPrefabs = I18nHelpers.GetAllFilesPathsByExtension(".prefab");

            foreach (var prefab in allPrefabs)
            {
                var o       = AssetDatabase.LoadMainAssetAtPath(prefab) as GameObject;
                var scripts = o.GetComponentsInChildren <LocalizeLabel>(true);
                foreach (var item in scripts)
                {
                    if (string.IsNullOrEmpty(item.Key))
                    {
                        continue;
                    }
                    AddToStorage(storage, item.Key, item.GetText(), item.GetHint(), Source.PrefabAndScene, PairStatus.New, prefab);
                }
            }
        }
Пример #2
0
        private void ApplyChanges()
        {
            _data = new SortedDictionary <string, LocalizationRecord>();
            foreach (var keyValuePair in _mixedData)
            {
                if (keyValuePair.Value.Status != PairStatus.Removed)
                {
                    _data.Add(keyValuePair.Key, keyValuePair.Value);
                }
            }

            var rawData = new List <string[]>();

            foreach (var item in _data)
            {
                item.Value.Status = PairStatus.NoneChanged;

                rawData.Add(new[] {
                    item.Key,
                    I18nService.Screen(string.IsNullOrEmpty(item.Value.Value) ? item.Key + "_Value" : item.Value.Value),
                    I18nService.Screen(item.Value.Hint),
                    item.Value.Source.ToString()
                });
            }

            var source = I18nHelpers.BuildCSV(rawData);

            source = I18nService.UnScreen(source);

            var writer = new StreamWriter(PathToFile, false);

            writer.Write(source);
            writer.Close();

            AssetDatabase.SaveAssets();
            AssetDatabase.Refresh();

            RevertChanges();
        }