Sin descripción
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.

SceneViewOpenTilePaletteOverlay.cs 3.0KB

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