Event AssetChanged
Provides a callback that will be invoked when the asset is available or has changed.
Namespace: UnityEngine .Localization
Assembly: Unity.Localization.dll
Syntax
public event LocalizedAsset<TObject>.ChangeHandler AssetChanged
Returns
Type | Description |
---|---|
Localized |
Remarks
The following events will trigger an update:
- The first time the action is added to the event.
- The Selected
Locale changing. - The Table
Reference or TableEntry changing.Reference
When the first Localized
Examples
This example shows how the Asset
public class LocalizedTextWithFont : MonoBehaviour
{
[Serializable]
public class LocalizedFont : LocalizedAsset<Font> {}
public LocalizedString localizedString;
public LocalizedFont localizedFont;
public Text uiText;
void OnEnable()
{
localizedString.StringChanged += UpdateText;
localizedFont.AssetChanged += FontChanged;
}
void OnDisable()
{
localizedString.StringChanged -= UpdateText;
localizedFont.AssetChanged -= FontChanged;
}
void FontChanged(Font f)
{
uiText.font = f;
}
void UpdateText(string s)
{
uiText.text = s;
}
}