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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
153
|
+
{
|
|
154
|
+
Undo.AddComponent<LocalizationComponent>(text.gameObject);
|
|
155
|
+
EditorSceneManager.MarkSceneDirty(text.gameObject.scene);
|
|
156
|
+
}
|
|
140
157
|
else
|
|
141
|
-
|
|
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
|
}
|