fix: 3D文字翻译重构 - 分离车辆名称/厂区名称/后缀独立翻译

- Text3DCtrl: 新增SetName(text, area, suffix)重载,各部分独立翻译
- CarCtrl.Update3DText: 从carName中分离(1)等后缀,纯名称查翻译表
- 修复车辆展开后名称含中文问题(组合字符串无法匹配翻译表)
- 修复收起/展开后文字不刷新问题(LanguageChanged事件重建文本)
This commit is contained in:
ayuan9957 2026-07-16 16:25:50 +08:00
parent 8941d8b497
commit 6909b1c7b4
2 changed files with 31 additions and 5 deletions

View File

@ -332,14 +332,18 @@ public class CarCtrl : MonoBehaviour, IBindIcon,IShowName3DText
//if (Text3DCtrl_Names == null)
// Text3DCtrl_Names = this.GetComponentsInChildren<Text3DCtrl>();
string textValue = data.carName;
if (!string.IsNullOrEmpty(inAreaName))
string carName = data.carName;
string nameSuffix = "";
int idx = carName.IndexOf('(');
if (idx > 0)
{
textValue = $"{textValue}({inAreaName})";
nameSuffix = carName.Substring(idx);
carName = carName.Substring(0, idx);
}
string areaName = inAreaName;
for (int i = 0; i < Text3DCtrl_Names.Length; i++)
{
Text3DCtrl_Names[i]?.SetName(textValue);
Text3DCtrl_Names[i]?.SetName(carName, areaName, nameSuffix);
}
}

View File

@ -9,6 +9,8 @@ public class Text3DCtrl : MonoBehaviour
Transform targetTrans;
float angleX;
string sourceText;
string extraText;
string suffixText;
public void SetLayer(string LayerName)
{
@ -48,9 +50,29 @@ public class Text3DCtrl : MonoBehaviour
public void SetName(string text)
{
sourceText = text;
extraText = null;
suffixText = null;
textMesh.text = LocalizationManager.Get(text);
}
public void SetName(string text, string area, string suffix = null)
{
sourceText = text;
extraText = area;
suffixText = suffix;
UpdateDisplayText();
}
private void UpdateDisplayText()
{
string name = LocalizationManager.Get(sourceText);
if (!string.IsNullOrEmpty(suffixText))
name += suffixText;
if (!string.IsNullOrEmpty(extraText))
name = $"{name}({LocalizationManager.Get(extraText)})";
textMesh.text = name;
}
//选选取的时候 改变文字颜色
public void ChangeTextColor(Color newColor)
{
@ -65,7 +87,7 @@ public class Text3DCtrl : MonoBehaviour
private void OnLanguageChanged()
{
if (!string.IsNullOrEmpty(sourceText))
textMesh.text = LocalizationManager.Get(sourceText);
UpdateDisplayText();
}
void OnDestroy()