No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

VisualElementExtensions.cs 944B

1234567891011121314151617181920212223242526272829
  1. using UnityEngine.UIElements;
  2. namespace UnityEditor.U2D.Common
  3. {
  4. internal static class VisualElementExtensions
  5. {
  6. public static void SetHiddenFromLayout(this VisualElement element, bool isHidden)
  7. {
  8. if (isHidden)
  9. {
  10. element.SetEnabled(false);
  11. element.style.display = DisplayStyle.None;
  12. element.style.position = Position.Absolute;
  13. }
  14. else
  15. {
  16. element.SetEnabled(true);
  17. element.style.display = DisplayStyle.Flex;
  18. element.style.position = Position.Relative;
  19. }
  20. }
  21. public static void LocalizeTextInChildren(this VisualElement element)
  22. {
  23. element.Query<TextElement>().ForEach((e) => e.text = L10n.Tr(e.text));
  24. element.Query<Button>().ForEach((e) => e.tooltip = L10n.Tr(e.tooltip));
  25. }
  26. }
  27. }