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.

TilePaletteBrushesDropdownToggle.cs 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. using UnityEditor.Toolbars;
  2. using UnityEngine;
  3. using UnityEngine.UIElements;
  4. namespace UnityEditor.Tilemaps
  5. {
  6. [EditorToolbarElement(k_ToolbarId)]
  7. internal class TilePaletteBrushesDropdownToggle : EditorToolbarToggle
  8. {
  9. internal const string k_ToolbarId = "Tile Palette/Brushes Dropdown Toggle";
  10. private new static readonly string ussClassName = "unity-tilepalette-brushesdropdown-toggle";
  11. private static readonly string k_IconPath = "Packages/com.unity.2d.tilemap/Editor/Icons/Tilemap.BrushSettings.png";
  12. private static readonly string k_Tooltip = L10n.Tr("Toggles the visibility of the Brush Settings Overlay");
  13. public TilePaletteBrushesDropdownToggle()
  14. {
  15. AddToClassList(ussClassName);
  16. TilePaletteOverlayUtility.SetStyleSheet(this);
  17. RegisterCallback<DetachFromPanelEvent>(OnDetachFromPanel);
  18. icon = EditorGUIUtility.LoadIcon(k_IconPath);
  19. tooltip = k_Tooltip;
  20. var input = this.Q<VisualElement>(className: Toggle.inputUssClassName);
  21. var arrow = new VisualElement();
  22. arrow.AddToClassList("unity-icon-arrow");
  23. arrow.pickingMode = PickingMode.Ignore;
  24. input.Add(arrow);
  25. }
  26. public override bool value
  27. {
  28. get => base.value;
  29. set
  30. {
  31. base.value = value;
  32. if (value)
  33. {
  34. ClickEvent();
  35. }
  36. else
  37. {
  38. CloseEvent();
  39. }
  40. }
  41. }
  42. private void ClickEvent()
  43. {
  44. BoolFieldOverlayPopupWindow.ShowOverlayPopup<TilePaletteBrushInspectorPopup>(this, new Vector2(300, 180), false);
  45. }
  46. private void CloseEvent()
  47. {
  48. BoolFieldOverlayPopupWindow.CloseAllWindows<TilePaletteBrushInspectorPopup>();
  49. }
  50. private void OnDetachFromPanel(DetachFromPanelEvent evt)
  51. {
  52. CloseEvent();
  53. }
  54. }
  55. }