Class LocalizedAssetBehaviour<TObject, TReference>
Abstract class that can be inherited from to create a general purpose Localized Asset Component. This Component handles the Localization of the asset and calls UpdateAsset(TObject) whenever a new Localized Asset is ready.
Namespace: UnityEngine.Localization.Components
Syntax
public abstract class LocalizedAssetBehaviour<TObject, TReference> : LocalizedMonoBehaviour where TObject : Object where TReference : LocalizedAsset<TObject>, new()
Type Parameters
Name | Description |
---|---|
TObject | The type of Asset to be Localized. Must inherit from UnityEngine.Object |
TReference | The Serializable LocalizedAsset class. This will be used for the AssetReference property. |
Examples
This example shows how the Font asset of a UGUI Text Component could be localized.
using System;
using UnityEngine;
using UnityEngine.Localization;
using UnityEngine.Localization.Components;
using UnityEngine.UI;
[Serializable]
public class LocalizedFont : LocalizedAsset<Font> {}
public class LocalizedFontComponent : LocalizedAssetBehaviour<Font, LocalizedFont>
{
public Text text;
protected override void UpdateAsset(Font localizedFont)
{
text.font = localizedFont;
}
}
Properties
AssetReference
Reference to the Table and Entry which will be used to identify the asset being localized.
Declaration
public TReference AssetReference { get; set; }
Property Value
Type | Description |
---|---|
TReference |
Methods
UpdateAsset(TObject)
Called when AssetReference has been loaded. This will occur when the game first starts after InitializationOperation has completed and whenever the SelectedLocale is changed.
Declaration
protected abstract void UpdateAsset(TObject localizedAsset)
Parameters
Type | Name | Description |
---|---|---|
TObject | localizedAsset |