Event StringChanged
Provides a callback that will be invoked when the translated string has changed. The following events will trigger an update:
- The first time the action is added to the event.
- The SelectedLocale changing.
- If the string is currently using a IVariable which supports IVariableValueChanged and it's value has changed.
- When RefreshString() is called.
- The TableReference or TableEntryReference changing.
Namespace: UnityEngine.Localization
Assembly: Unity.Localization.dll
Syntax
public event LocalizedString.ChangeHandler StringChanged
Returns
Type | Description |
---|---|
LocalizedString.ChangeHandler |
Examples
This example shows how the StringChanged event can be used to trigger updates to a string.
public class LocalizedStringWithEvents : MonoBehaviour
{
public LocalizedString myString;
string localizedText;
/// <summary>
/// Register a ChangeHandler. This is called whenever the string needs to be updated.
/// </summary>
void OnEnable()
{
myString.StringChanged += UpdateString;
}
void OnDisable()
{
myString.StringChanged -= UpdateString;
}
void UpdateString(string s)
{
localizedText = s;
}
void OnGUI()
{
EditorGUILayout.LabelField(localizedText);
}
}