public void SetTableSelected(LocalizationAssetTableSO tableSelected) { TableSelected = tableSelected; TextTableName = tableSelected.TableName; RegisteredTableName = tableSelected.TableName; EditingTableName = tableSelected.TableName; }
//========================================== // Methods //========================================== #region Methods #region Constructors / Lifecycle public AssetTablesInformations(LocalizationAssetTableSO tableSelected) { TableSelected = tableSelected; CreateTableSelected = null; EditingTableName = (tableSelected != null) ? (tableSelected.TableName) : (""); RegisteredTableName = (tableSelected != null) ? (tableSelected.TableName) : (""); TextTableName = (tableSelected != null) ? (tableSelected.TableName) : (""); _mLanguages = new List <LocaleLanguageEditor>(); }
private void Footer(Rect rect) { GUILayout.BeginVertical(); GUILayout.BeginHorizontal(); EditorGUI.BeginChangeCheck(); GUILayout.Label("Key Mapper", GUILayout.MaxWidth(100)); _mInformations.CreateTableSelected = (LocalizationAssetTableSO)EditorGUILayout.ObjectField(_mInformations.CreateTableSelected, typeof(LocalizationAssetTableSO), false); GUILayout.EndHorizontal(); if (EditorGUI.EndChangeCheck()) { Repaint(); } if (_mInformations.CreateTableSelected == null) { GUILayout.BeginHorizontal(); GUILayout.Label("Table name", GUILayout.MaxWidth(100)); _mInformations.TextTableName = GUILayout.TextField(_mInformations.TextTableName); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Type", GUILayout.MaxWidth(100)); LocalizationAssetType type = LocalizationAssetType.Audio; type = (LocalizationAssetType)EditorGUILayout.EnumPopup(type); GUILayout.EndHorizontal(); } GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("Create", GUILayout.MaxWidth(100))) { if (_mLocalization != null && _mInformations.CreateTableSelected) { LocalizationAssetTableSO table = _mInformations.CreateTableSelected; string tablePath = AssetDatabase.GetAssetPath(table); string tableFolderPath = Path.GetDirectoryName(tablePath); foreach (LocaleLanguageEditor language in _mInformations.GetLanguagesSelected()) { string potentialPath = Path.Combine(tableFolderPath, table.TableName + " - " + language._mName + ".asset"); LocalizationLocaleSO locale = _mLocalization.GetLocale(language._mLanguage); if (locale != null && table.LocaleAssetExist(language._mLanguage) == false && File.Exists(potentialPath) == false) { LocalizationLocaleAssetsSO localeAssets = ScriptableObject.CreateInstance <LocalizationLocaleAssetsSO>(); localeAssets.Init(language._mLanguage); table.LocalesAssets.Add(localeAssets); AssetDatabase.CreateAsset(localeAssets, potentialPath); EditorUtility.SetDirty(table); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); } } } else if (_mLocalization != null && string.IsNullOrEmpty(_mInformations.TextTableName) == false && _mLocalization.AssetsTableExists(_mInformations.TextTableName) == false) { List <LocalizationLocaleAssetsSO> localesAssets = new List <LocalizationLocaleAssetsSO>(); string pathLocalizationAsset = AssetDatabase.GetAssetPath(_mLocalization); string pathLocalizationFolder = Path.GetDirectoryName(pathLocalizationAsset); string tableName = _mInformations.TextTableName; AssetDatabase.CreateFolder(pathLocalizationFolder, tableName); // Create the sub asset for locale foreach (LocaleLanguageEditor language in _mInformations.GetLanguagesSelected()) { LocalizationLocaleSO locale = _mLocalization.GetLocale(language._mLanguage); if (locale != null) { string pathAssetTableLocale = Path.Combine(pathLocalizationFolder, tableName, _mInformations.TextTableName + " - " + language._mName + ".asset"); LocalizationLocaleAssetsSO localeAssets = ScriptableObject.CreateInstance <LocalizationLocaleAssetsSO>(); localeAssets.Init(language._mLanguage); localesAssets.Add(localeAssets); AssetDatabase.CreateAsset(localeAssets, pathAssetTableLocale); } } // Create the asset table string pathAssetTable = Path.Combine(pathLocalizationFolder, tableName, _mInformations.TextTableName + " - Mapper.asset"); LocalizationAssetTableSO table = ScriptableObject.CreateInstance <LocalizationAssetTableSO>(); table.Init(_mInformations.TextTableName, localesAssets); _mLocalization.AddAssetTable(table); AssetDatabase.CreateAsset(table, pathAssetTable); EditorUtility.SetDirty(_mLocalization); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); } } GUILayout.EndHorizontal(); GUILayout.EndVertical(); }