com.xmobitea.changx.mini-localization 1.4.3 → 1.4.5

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
  }
@@ -234,7 +234,7 @@
234
234
 
235
235
  public static string GetText(string key)
236
236
  {
237
- if (!IsExists) return "Loading...";
237
+ if (!IsExists) return key;
238
238
 
239
239
  if (string.IsNullOrEmpty(key) || !Instance.textLocalizationDic.ContainsKey(key)) return key;
240
240
 
@@ -3,7 +3,9 @@
3
3
  "rootNamespace": "",
4
4
  "references": [
5
5
  "com.xmobitea.changx.mini-singleton.runtime",
6
- "Unity.TextMeshPro"
6
+ "Unity.TextMeshPro",
7
+ "Unity.Addressables",
8
+ "Unity.ResourceManager"
7
9
  ],
8
10
  "includePlatforms": [],
9
11
  "excludePlatforms": [],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "com.xmobitea.changx.mini-localization",
3
- "version": "1.4.3",
3
+ "version": "1.4.5",
4
4
  "displayName": "XmobiTea Localization",
5
5
  "description": "XmobiTea Unity package",
6
6
  "unity": "2020.3",