A game about forced loneliness, made by TACStudios
at master 3.1 kB view raw
1using UnityEditor.Overlays; 2using UnityEditor.Toolbars; 3using UnityEngine; 4using UnityEngine.UIElements.Experimental; 5 6namespace UnityEditor.Tilemaps 7{ 8 [Overlay(typeof(SceneView), k_OverlayId, k_DisplayName 9 , defaultDockZone = DockZone.RightColumn 10 , defaultDockPosition = DockPosition.Bottom 11 , defaultDockIndex = 0 12 , defaultLayout = Layout.Panel)] 13 internal class SceneViewOpenTilePaletteOverlay : ToolbarOverlay, ITransientOverlay 14 { 15 internal const string k_OverlayId = "Scene View/Open Tile Palette"; 16 private const string k_DisplayName = "Open Tile Palette"; 17 18 public SceneViewOpenTilePaletteOverlay() : base(TilePaletteOpenPalette.k_ToolbarId) {} 19 20 public bool visible => SceneViewOpenTilePaletteHelper.showInSceneViewActive && SceneViewOpenTilePaletteHelper.IsActive(); 21 } 22 23 [EditorToolbarElement(k_ToolbarId)] 24 sealed class TilePaletteOpenPalette : EditorToolbarButton 25 { 26 internal const string k_ToolbarId = "Tile Palette/Open Palette"; 27 28 const string k_ToolSettingsClass = "unity-tool-settings"; 29 30 private static string k_LabelText = L10n.Tr("Open Tile Palette"); 31 private static string k_TooltipText = L10n.Tr("Opens the Tile Palette Window"); 32 private const string k_IconPath = "Packages/com.unity.2d.tilemap/Editor/Icons/Tilemap.TilePalette.png"; 33 34 private IValueAnimation currentAnim; 35 36 public TilePaletteOpenPalette() : base(SceneViewOpenTilePaletteHelper.OpenTilePalette) 37 { 38 name = "Open Tile Palette"; 39 AddToClassList(k_ToolSettingsClass); 40 41 icon = EditorGUIUtility.LoadIconRequired(k_IconPath); 42 text = k_LabelText; 43 tooltip = k_TooltipText; 44 45 if (!SceneViewOpenTilePaletteHelper.highlight) 46 return; 47 48 var anim = experimental.animation.Start( 49 new StyleValues() 50 { 51 borderColor = Color.yellow, 52 borderTopWidth = 1, 53 borderBottomWidth = 1, 54 borderLeftWidth = 1, 55 borderRightWidth = 1, 56 marginLeft = 1, 57 marginRight = 1, 58 }, 59 new StyleValues() 60 { 61 borderColor = Color.clear, 62 borderTopWidth = 1, 63 borderBottomWidth = 1, 64 borderLeftWidth = 1, 65 borderRightWidth = 1, 66 marginLeft = 1, 67 marginRight = 1, 68 }, 3000).Ease(Easing.OutQuad); 69 anim.OnCompleted(() => ClearAnim(anim)); 70 currentAnim = anim; 71 SceneViewOpenTilePaletteHelper.highlight = false; 72 } 73 74 void ClearAnim(IValueAnimation anim) 75 { 76 if (currentAnim != null && currentAnim == anim) 77 { 78 currentAnim = null; 79 anim.Stop(); 80 anim.Recycle(); 81 } 82 } 83 } 84}