Files
BlueRoseNote/03-UnrealEngine/卡通渲染相关资料/渲染功能/ARC/UI/UMG本地化.md

61 lines
1.4 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
title: UMG本地化
date: 2026-05-03 00:00:00
excerpt: 平台感知的多语言文本系统(平台后缀、语言 ID
tags:
- ARC
- UI
- UMG
- Localization
rating: ⭐
---
# UMG 本地化
返回 [[UI]]
## 概述
ARC 引擎为 UMG 文本系统添加了平台感知的本地化机制,允许同一文本 ID 在不同平台上显示不同内容(例如按钮提示文本因平台不同而变化)。
## 平台后缀系统
文本 ID 查找时自动追加平台后缀:
| 平台 | 后缀 |
|------|------|
| PS5 | `_PS5` |
| Xbox Series X | `_XSX` |
| 其他 | 无后缀(使用默认文本) |
查找顺序:
1. 先查 `TextID_PS5`(或 `_XSX`
2. 找不到则回退到 `TextID`
## 语言 ID
新增 CVar `sg_REDLanguageID`,允许运行时切换语言而不依赖系统语言设置:
```cpp
static TAutoConsoleVariable<int32> CVarREDLanguageID(
TEXT("sg.REDLanguageID"),
0,
TEXT("Override language ID for RED localization"));
```
## 自定义 L10N 加载
`Source/Runtime/Core/` 中的本地化文件加载逻辑支持自定义 L10N 目录。
## 兼容性
`UOldRichTextBlockDecorator` 兼容层确保旧版富文本格式在新系统中正常工作。
## 修改文件列表
涉及 `Source/Runtime/UMG/` 下约 12 个文件,主要覆盖:
- `TextBlock` 相关 — 平台后缀查找
- `TextWidgetTypes` — 垂直对齐(与 [[Slate扩展]] 配合)
- `RichTextBlockDecorator` — 兼容层
- `WidgetComponent` — 修改