mirror of
https://github.com/peng-zhihui/ElectronBot.git
synced 2026-10-21 22:56:26 +08:00
88 lines
1.7 KiB
C#
88 lines
1.7 KiB
C#
namespace UIWidgets
|
|
{
|
|
using UIWidgets.l10n;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
/// <summary>
|
|
/// TreeGraph component with icons.
|
|
/// </summary>
|
|
public class TreeGraphComponentIcons : TreeGraphComponent<TreeViewItem>, IUpgradeable
|
|
{
|
|
/// <summary>
|
|
/// Name.
|
|
/// </summary>
|
|
[SerializeField]
|
|
[HideInInspector]
|
|
[System.Obsolete("Replaced with NameAdapter.")]
|
|
public Text Name;
|
|
|
|
/// <summary>
|
|
/// Name.
|
|
/// </summary>
|
|
[SerializeField]
|
|
public TextAdapter NameAdapter;
|
|
|
|
/// <summary>
|
|
/// Init graphics foreground.
|
|
/// </summary>
|
|
protected override void GraphicsForegroundInit()
|
|
{
|
|
if (GraphicsForegroundVersion == 0)
|
|
{
|
|
graphicsForeground = new Graphic[] { UtilitiesUI.GetGraphic(NameAdapter), };
|
|
GraphicsForegroundVersion = 1;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Process locale changes.
|
|
/// </summary>
|
|
public override void LocaleChanged()
|
|
{
|
|
UpdateName();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Update display name.
|
|
/// </summary>
|
|
protected virtual void UpdateName()
|
|
{
|
|
NameAdapter.text = Node.Item.LocalizedName ?? Localization.GetTranslation(Node.Item.Name);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Set data.
|
|
/// </summary>
|
|
/// <param name="node">Node.</param>
|
|
public override void SetData(TreeNode<TreeViewItem> node)
|
|
{
|
|
Node = node;
|
|
|
|
name = Node.Item.Name;
|
|
UpdateName();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Upgrade this instance.
|
|
/// </summary>
|
|
public virtual void Upgrade()
|
|
{
|
|
#pragma warning disable 0612, 0618
|
|
Utilities.GetOrAddComponent(Name, ref NameAdapter);
|
|
#pragma warning restore 0612, 0618
|
|
}
|
|
|
|
#if UNITY_EDITOR
|
|
/// <summary>
|
|
/// Validate this instance.
|
|
/// </summary>
|
|
protected override void OnValidate()
|
|
{
|
|
Compatibility.Upgrade(this);
|
|
|
|
base.OnValidate();
|
|
}
|
|
#endif
|
|
}
|
|
} |