Singularity/Library/PackageCache/com.unity.2d.animation@7.0.10/Editor/SkinningModule/UI/VisualElementExtensions.cs

30 lines
947 B
C#
Raw Permalink Normal View History

2024-05-06 14:45:45 -04:00
using UnityEngine.UIElements;
namespace UnityEditor.U2D.Animation
{
internal static class VisualElementExtensions
{
public static void SetHiddenFromLayout(this VisualElement element, bool isHidden)
{
if (isHidden)
{
element.SetEnabled(false);
element.style.display = DisplayStyle.None;
element.style.position = Position.Absolute;
}
else
{
element.SetEnabled(true);
element.style.display = DisplayStyle.Flex;
element.style.position = Position.Relative;
}
}
public static void LocalizeTextInChildren(this VisualElement element)
{
element.Query<TextElement>().ForEach((e) => e.text = L10n.Tr(e.text));
element.Query<Button>().ForEach((e) => e.tooltip = L10n.Tr(e.tooltip));
}
}
}