123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- using UnityEditor.Toolbars;
- using UnityEngine;
- using UnityEngine.UIElements;
-
- namespace UnityEditor.Tilemaps
- {
- [EditorToolbarElement(k_ToolbarId)]
- internal class TilePaletteBrushesDropdownToggle : EditorToolbarToggle
- {
- internal const string k_ToolbarId = "Tile Palette/Brushes Dropdown Toggle";
-
- private new static readonly string ussClassName = "unity-tilepalette-brushesdropdown-toggle";
-
- private static readonly string k_IconPath = "Packages/com.unity.2d.tilemap/Editor/Icons/Tilemap.BrushSettings.png";
- private static readonly string k_Tooltip = L10n.Tr("Toggles the visibility of the Brush Settings Overlay");
-
- public TilePaletteBrushesDropdownToggle()
- {
- AddToClassList(ussClassName);
- TilePaletteOverlayUtility.SetStyleSheet(this);
-
- RegisterCallback<DetachFromPanelEvent>(OnDetachFromPanel);
-
- icon = EditorGUIUtility.LoadIcon(k_IconPath);
- tooltip = k_Tooltip;
-
- var input = this.Q<VisualElement>(className: Toggle.inputUssClassName);
- var arrow = new VisualElement();
- arrow.AddToClassList("unity-icon-arrow");
- arrow.pickingMode = PickingMode.Ignore;
- input.Add(arrow);
- }
-
- public override bool value
- {
- get => base.value;
- set
- {
- base.value = value;
- if (value)
- {
- ClickEvent();
- }
- else
- {
- CloseEvent();
- }
- }
- }
-
- private void ClickEvent()
- {
- BoolFieldOverlayPopupWindow.ShowOverlayPopup<TilePaletteBrushInspectorPopup>(this, new Vector2(300, 180), false);
- }
-
- private void CloseEvent()
- {
- BoolFieldOverlayPopupWindow.CloseAllWindows<TilePaletteBrushInspectorPopup>();
- }
-
- private void OnDetachFromPanel(DetachFromPanelEvent evt)
- {
- CloseEvent();
- }
- }
- }
|