com.xmobitea.changx.mini-localization 1.4.4 → 1.4.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,6 +7,7 @@
7
7
  using UnityEngine.UI;
8
8
  using UnityEditor.IMGUI.Controls;
9
9
  using TMPro;
10
+ using UnityEditor.SceneManagement;
10
11
 
11
12
  public class LocalizationComponentWindowsEditor : EditorWindow
12
13
  {
@@ -101,7 +102,18 @@
101
102
  var localizationComponent = text.GetComponent<LocalizationComponentBase>();
102
103
  if (localizationComponent)
103
104
  {
104
- localizationComponent.Key = GUILayout.TextField(localizationComponent.Key, GUILayout.Width(maxWidth * 2 / 5));
105
+ EditorGUI.BeginChangeCheck();
106
+
107
+ var newKey = GUILayout.TextField(
108
+ localizationComponent.Key,
109
+ GUILayout.Width(maxWidth * 2 / 5)
110
+ );
111
+
112
+ if (EditorGUI.EndChangeCheck())
113
+ {
114
+ localizationComponent.Key = newKey;
115
+ MarkDirty(localizationComponent);
116
+ }
105
117
 
106
118
  var keys = LocalizationKeyDrawer.GetKeys();
107
119
 
@@ -111,13 +123,15 @@
111
123
  var dropdown = new LocalizationDropdown(dropdownState, keys, selectedKey =>
112
124
  {
113
125
  localizationComponent.Key = selectedKey;
126
+ MarkDirty(localizationComponent);
114
127
  });
115
128
  dropdown.Show(buttonRect);
116
129
  }
117
130
 
118
131
  if (GUILayout.Button("Remove", GUILayout.Width(maxWidth / 5)))
119
132
  {
120
- DestroyImmediate(localizationComponent, true);
133
+ Undo.DestroyObjectImmediate(localizationComponent);
134
+ EditorSceneManager.MarkSceneDirty(text.gameObject.scene);
121
135
  }
122
136
 
123
137
  if (!string.IsNullOrEmpty(localizationComponent.Key))
@@ -136,9 +150,15 @@
136
150
  if (GUILayout.Button("Add LocalizationComponent", GUILayout.Width(maxWidth * 2 / 5)))
137
151
  {
138
152
  if (text.GetComponent<Text>() != null)
139
- localizationComponent = text.gameObject.AddComponent<LocalizationComponent>();
153
+ {
154
+ Undo.AddComponent<LocalizationComponent>(text.gameObject);
155
+ EditorSceneManager.MarkSceneDirty(text.gameObject.scene);
156
+ }
140
157
  else
141
- localizationComponent = text.gameObject.AddComponent<TMP_LocalizationComponent>();
158
+ {
159
+ Undo.AddComponent<TMP_LocalizationComponent>(text.gameObject);
160
+ EditorSceneManager.MarkSceneDirty(text.gameObject.scene);
161
+ }
142
162
 
143
163
  Selection.objects = new Object[] { text.gameObject };
144
164
  }
@@ -154,5 +174,19 @@
154
174
 
155
175
  Repaint();
156
176
  }
177
+
178
+ void MarkDirty(UnityEngine.Component comp)
179
+ {
180
+ if (comp == null) return;
181
+
182
+ Undo.RecordObject(comp, "Localization Change");
183
+ EditorUtility.SetDirty(comp);
184
+
185
+ if (!EditorApplication.isPlaying)
186
+ {
187
+ EditorSceneManager.MarkSceneDirty(comp.gameObject.scene);
188
+ }
189
+ }
190
+
157
191
  }
158
192
  }
@@ -12,7 +12,7 @@
12
12
  [CustomEditor(typeof(LocalizationManager))]
13
13
  public class LocalizationManagerEditor : Editor
14
14
  {
15
- private const string Version = "1.4.2";
15
+ private const string Version = "1.4.6";
16
16
  private const string Library = @".\Library\PackageCache\com.xmobitea.changx.mini-localization@" + Version;
17
17
  //private const string Library = @".\Assets\MiniLocalization";
18
18
  private const string ProcessPath = @"\Editor\Tools\GetLocalizationTools";
@@ -209,6 +209,10 @@
209
209
 
210
210
  contentBuilder.AppendLine(" public const string " + validKey + " = " + "\"" + key + "\";");
211
211
  }
212
+ else
213
+ {
214
+ Debug.LogError("[Localization] Dupplicate key " + key);
215
+ }
212
216
  }
213
217
  }
214
218
 
@@ -97,7 +97,7 @@
97
97
  }
98
98
 
99
99
  #if ADDRESSABLE
100
- if (thisLanguage.XMLRef != null)
100
+ if (thisLanguage.XMLRef != null && thisLanguage.XMLRef.RuntimeKeyIsValid())
101
101
  {
102
102
  thisLanguage.XMLRef.LoadAssetAsync().Completed += (handle) =>
103
103
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "com.xmobitea.changx.mini-localization",
3
- "version": "1.4.4",
3
+ "version": "1.4.6",
4
4
  "displayName": "XmobiTea Localization",
5
5
  "description": "XmobiTea Unity package",
6
6
  "unity": "2020.3",