Skip to content

Commit 9b8b9e7

Browse files
committed
fix: localize added in text mehs pro
1 parent 0821efc commit 9b8b9e7

2 files changed

Lines changed: 161 additions & 3 deletions

File tree

Assets/Code/Localization/Editor/LocalizationEditorWindow.cs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,23 +207,32 @@ private void AddTMP_LocalizersToResources()
207207
if (string.IsNullOrEmpty(path)) continue;
208208

209209
var root = PrefabUtility.LoadPrefabContents(path);
210-
var texts = root.GetComponentsInChildren<TMP_Text>(true);
210+
bool wasModified = false;
211211

212+
var texts = root.GetComponentsInChildren<TMP_Text>(true);
212213
foreach (var text in texts)
213214
{
214215
if (text.GetComponent<LocalizeBase>() == null)
215216
{
216-
Undo.RecordObject(text.gameObject, "Add TMP_Localizer");
217+
Undo.RegisterCompleteObjectUndo(text.gameObject, "Add TMP_Localizer");
217218
text.gameObject.AddComponent<TMP_Localizer>();
219+
EditorUtility.SetDirty(text.gameObject);
220+
wasModified = true;
218221
addedCount++;
219222
}
220223
}
221224

222-
PrefabUtility.SaveAsPrefabAsset(root, path);
225+
if (wasModified)
226+
{
227+
EditorUtility.SetDirty(root); // 💡 чтобы точно зафиксировалось
228+
PrefabUtility.SaveAsPrefabAsset(root, path);
229+
}
230+
223231
PrefabUtility.UnloadPrefabContents(root);
224232
}
225233

226234
AssetDatabase.SaveAssets();
235+
AssetDatabase.Refresh();
227236
Debug.Log($"✅ Added TMP_Localizer to {addedCount} TMP_Text objects.");
228237
}
229238

Assets/Resources/UI/GameHud.prefab

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,154 @@ MonoBehaviour:
150150
m_Name:
151151
m_EditorClassIdentifier:
152152
localizationKey:
153+
--- !u!1 &466823661904961022
154+
GameObject:
155+
m_ObjectHideFlags: 0
156+
m_CorrespondingSourceObject: {fileID: 0}
157+
m_PrefabInstance: {fileID: 0}
158+
m_PrefabAsset: {fileID: 0}
159+
serializedVersion: 6
160+
m_Component:
161+
- component: {fileID: 6733204108145327487}
162+
- component: {fileID: 1112728623499522228}
163+
- component: {fileID: 5411053735382755500}
164+
- component: {fileID: 5334769004505123377}
165+
m_Layer: 5
166+
m_Name: Text_Name
167+
m_TagString: Untagged
168+
m_Icon: {fileID: 0}
169+
m_NavMeshLayer: 0
170+
m_StaticEditorFlags: 0
171+
m_IsActive: 1
172+
--- !u!224 &6733204108145327487
173+
RectTransform:
174+
m_ObjectHideFlags: 0
175+
m_CorrespondingSourceObject: {fileID: 0}
176+
m_PrefabInstance: {fileID: 0}
177+
m_PrefabAsset: {fileID: 0}
178+
m_GameObject: {fileID: 466823661904961022}
179+
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
180+
m_LocalPosition: {x: 0, y: 0, z: 0}
181+
m_LocalScale: {x: 1, y: 1, z: 1}
182+
m_ConstrainProportionsScale: 0
183+
m_Children: []
184+
m_Father: {fileID: 5962648131348975462}
185+
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
186+
m_AnchorMin: {x: 0.5, y: 0.5}
187+
m_AnchorMax: {x: 0.5, y: 0.5}
188+
m_AnchoredPosition: {x: 0, y: 0}
189+
m_SizeDelta: {x: 200, y: 50}
190+
m_Pivot: {x: 0.5, y: 0.5}
191+
--- !u!222 &1112728623499522228
192+
CanvasRenderer:
193+
m_ObjectHideFlags: 0
194+
m_CorrespondingSourceObject: {fileID: 0}
195+
m_PrefabInstance: {fileID: 0}
196+
m_PrefabAsset: {fileID: 0}
197+
m_GameObject: {fileID: 466823661904961022}
198+
m_CullTransparentMesh: 1
199+
--- !u!114 &5411053735382755500
200+
MonoBehaviour:
201+
m_ObjectHideFlags: 0
202+
m_CorrespondingSourceObject: {fileID: 0}
203+
m_PrefabInstance: {fileID: 0}
204+
m_PrefabAsset: {fileID: 0}
205+
m_GameObject: {fileID: 466823661904961022}
206+
m_Enabled: 1
207+
m_EditorHideFlags: 0
208+
m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3}
209+
m_Name:
210+
m_EditorClassIdentifier:
211+
m_Material: {fileID: 0}
212+
m_Color: {r: 1, g: 1, b: 1, a: 1}
213+
m_RaycastTarget: 1
214+
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
215+
m_Maskable: 1
216+
m_OnCullStateChanged:
217+
m_PersistentCalls:
218+
m_Calls: []
219+
m_text: New Text
220+
m_isRightToLeft: 0
221+
m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
222+
m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
223+
m_fontSharedMaterials: []
224+
m_fontMaterial: {fileID: 0}
225+
m_fontMaterials: []
226+
m_fontColor32:
227+
serializedVersion: 2
228+
rgba: 4294967295
229+
m_fontColor: {r: 1, g: 1, b: 1, a: 1}
230+
m_enableVertexGradient: 0
231+
m_colorMode: 3
232+
m_fontColorGradient:
233+
topLeft: {r: 1, g: 1, b: 1, a: 1}
234+
topRight: {r: 1, g: 1, b: 1, a: 1}
235+
bottomLeft: {r: 1, g: 1, b: 1, a: 1}
236+
bottomRight: {r: 1, g: 1, b: 1, a: 1}
237+
m_fontColorGradientPreset: {fileID: 0}
238+
m_spriteAsset: {fileID: 0}
239+
m_tintAllSprites: 0
240+
m_StyleSheet: {fileID: 0}
241+
m_TextStyleHashCode: -1183493901
242+
m_overrideHtmlColors: 0
243+
m_faceColor:
244+
serializedVersion: 2
245+
rgba: 4294967295
246+
m_fontSize: 36
247+
m_fontSizeBase: 36
248+
m_fontWeight: 400
249+
m_enableAutoSizing: 0
250+
m_fontSizeMin: 18
251+
m_fontSizeMax: 72
252+
m_fontStyle: 0
253+
m_HorizontalAlignment: 1
254+
m_VerticalAlignment: 256
255+
m_textAlignment: 65535
256+
m_characterSpacing: 0
257+
m_wordSpacing: 0
258+
m_lineSpacing: 0
259+
m_lineSpacingMax: 0
260+
m_paragraphSpacing: 0
261+
m_charWidthMaxAdj: 0
262+
m_enableWordWrapping: 1
263+
m_wordWrappingRatios: 0.4
264+
m_overflowMode: 0
265+
m_linkedTextComponent: {fileID: 0}
266+
parentLinkedComponent: {fileID: 0}
267+
m_enableKerning: 1
268+
m_enableExtraPadding: 0
269+
checkPaddingRequired: 0
270+
m_isRichText: 1
271+
m_parseCtrlCharacters: 1
272+
m_isOrthographic: 1
273+
m_isCullingEnabled: 0
274+
m_horizontalMapping: 0
275+
m_verticalMapping: 0
276+
m_uvLineOffset: 0
277+
m_geometrySortingOrder: 0
278+
m_IsTextObjectScaleStatic: 0
279+
m_VertexBufferAutoSizeReduction: 0
280+
m_useMaxVisibleDescender: 1
281+
m_pageToDisplay: 1
282+
m_margin: {x: 0, y: 0, z: 0, w: 0}
283+
m_isUsingLegacyAnimationComponent: 0
284+
m_isVolumetricText: 0
285+
m_hasFontAssetChanged: 0
286+
m_baseMaterial: {fileID: 0}
287+
m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
288+
--- !u!114 &5334769004505123377
289+
MonoBehaviour:
290+
m_ObjectHideFlags: 0
291+
m_CorrespondingSourceObject: {fileID: 0}
292+
m_PrefabInstance: {fileID: 0}
293+
m_PrefabAsset: {fileID: 0}
294+
m_GameObject: {fileID: 466823661904961022}
295+
m_Enabled: 1
296+
m_EditorHideFlags: 0
297+
m_Script: {fileID: 11500000, guid: 836a40dddfacaeb4384366e730750713, type: 3}
298+
m_Name:
299+
m_EditorClassIdentifier:
300+
localizationKey:
153301
--- !u!1 &1485126269429728214
154302
GameObject:
155303
m_ObjectHideFlags: 0
@@ -2466,6 +2614,7 @@ RectTransform:
24662614
m_Children:
24672615
- {fileID: 297070466131320601}
24682616
- {fileID: 8278398173702700151}
2617+
- {fileID: 6733204108145327487}
24692618
m_Father: {fileID: 6547191552835619457}
24702619
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
24712620
m_AnchorMin: {x: 0, y: 0}

0 commit comments

Comments
 (0)