namespace UIWidgets
{
using UIWidgets.l10n;
using UnityEngine;
using UnityEngine.UI;
///
/// TreeGraph component with icons.
///
public class TreeGraphComponentIcons : TreeGraphComponent, IUpgradeable
{
///
/// Name.
///
[SerializeField]
[HideInInspector]
[System.Obsolete("Replaced with NameAdapter.")]
public Text Name;
///
/// Name.
///
[SerializeField]
public TextAdapter NameAdapter;
///
/// Init graphics foreground.
///
protected override void GraphicsForegroundInit()
{
if (GraphicsForegroundVersion == 0)
{
graphicsForeground = new Graphic[] { UtilitiesUI.GetGraphic(NameAdapter), };
GraphicsForegroundVersion = 1;
}
}
///
/// Process locale changes.
///
public override void LocaleChanged()
{
UpdateName();
}
///
/// Update display name.
///
protected virtual void UpdateName()
{
NameAdapter.text = Node.Item.LocalizedName ?? Localization.GetTranslation(Node.Item.Name);
}
///
/// Set data.
///
/// Node.
public override void SetData(TreeNode node)
{
Node = node;
name = Node.Item.Name;
UpdateName();
}
///
/// Upgrade this instance.
///
public virtual void Upgrade()
{
#pragma warning disable 0612, 0618
Utilities.GetOrAddComponent(Name, ref NameAdapter);
#pragma warning restore 0612, 0618
}
#if UNITY_EDITOR
///
/// Validate this instance.
///
protected override void OnValidate()
{
Compatibility.Upgrade(this);
base.OnValidate();
}
#endif
}
}