31 lines
903 B
C#
31 lines
903 B
C#
using UnityEngine;
|
|||
|
|
|
||
|
|
namespace Ironspore
|
||
|
|
{
|
||
|
|
[RequireComponent(typeof(TextMesh))]
|
||
|
|
public sealed class LocalizedWorldLabel : MonoBehaviour
|
||
|
|
{
|
||
|
|
string key;
|
||
|
|
TextMesh label;
|
||
|
|
|
||
|
|
public void Initialize(string textKey)
|
||
|
|
{
|
||
|
|
key = textKey;
|
||
|
|
label = GetComponent<TextMesh>();
|
||
|
|
if (GameLocalization.Catalog && GameLocalization.Catalog.worldFont)
|
||
|
|
{
|
||
|
|
label.font = GameLocalization.Catalog.worldFont;
|
||
|
|
GetComponent<MeshRenderer>().sharedMaterial = label.font.material;
|
||
|
|
}
|
||
|
|
Refresh();
|
||
|
|
}
|
||
|
|
void OnEnable() => GameLocalization.Changed += Refresh;
|
||
|
|
void OnDisable() => GameLocalization.Changed -= Refresh;
|
||
|
|
void Refresh()
|
||
|
|
{
|
||
|
|
if (label && !string.IsNullOrEmpty(key))
|
||
|
|
label.text = GameLocalization.Text(key);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|