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.

UiUtils.cs 879B

12345678910111213141516171819202122232425262728293031323334
  1. #if SERVICES_SDK_CORE_ENABLED
  2. using System;
  3. using UnityEditor;
  4. using UnityEngine.UIElements;
  5. namespace UnityEngine.Advertisements.Editor
  6. {
  7. static class UiUtils
  8. {
  9. public static VisualElement GetUiFromTemplate(string templatePath)
  10. {
  11. var template = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>(templatePath);
  12. if (template == null)
  13. {
  14. return null;
  15. }
  16. return template.CloneTree().contentContainer;
  17. }
  18. public static void AddOnClickedForElement(this VisualElement self, Action onClicked, string elementName)
  19. {
  20. var link = self.Q(elementName);
  21. if (link is null)
  22. {
  23. return;
  24. }
  25. var clickable = new Clickable(onClicked);
  26. link.AddManipulator(clickable);
  27. }
  28. }
  29. }
  30. #endif