暂无描述
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

TilePaletteBrushInspectorPopup.cs 2.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. using System;
  2. using UnityEditor.Toolbars;
  3. using UnityEngine;
  4. using UnityEngine.UIElements;
  5. namespace UnityEditor.Tilemaps
  6. {
  7. internal class TilePaletteBrushInspectorPopup : BoolFieldOverlayPopupWindow
  8. {
  9. private static readonly string ussClassName = "unity-tilepalette-brushinspectorpopup";
  10. private static readonly string horizontalClassName = ussClassName + "__horizontal";
  11. private BaseField<bool> trigger;
  12. private bool isLocked;
  13. private Rect screenRect;
  14. private Vector2 size;
  15. public void CreateGUI()
  16. {
  17. rootVisualElement.AddToClassList(ussClassName);
  18. TilePaletteOverlayUtility.SetStyleSheet(rootVisualElement);
  19. var imguiContainer = new TilePaletteBrushInspectorElement();
  20. var horizontalElement = new VisualElement();
  21. horizontalElement.AddToClassList(horizontalClassName);
  22. var label = new Label("Brush Settings");
  23. horizontalElement.Add(label);
  24. this.rootVisualElement.Add(horizontalElement);
  25. this.rootVisualElement.Add(imguiContainer);
  26. }
  27. protected override void OnEnable()
  28. {
  29. SceneView.duringSceneGui += DuringSceneGui;
  30. }
  31. private void DuringSceneGui(SceneView obj)
  32. {
  33. if (Event.current.isMouse)
  34. this.Repaint();
  35. }
  36. protected override void OnDisable()
  37. {
  38. SceneView.duringSceneGui -= DuringSceneGui;
  39. base.OnDisable();
  40. }
  41. }
  42. [EditorToolbarElement(k_ToolbarId)]
  43. internal sealed class TilePaletteBrushInspectorLockToggle : EditorToolbarToggle
  44. {
  45. internal const string k_ToolbarId = "Tile Palette/Brush Inspector Lock";
  46. private const string k_ToolSettingsClass = "unity-tool-settings";
  47. private static string k_TooltipText = L10n.Tr("Locks the Brush Inspector");
  48. public Action<bool> ToggleChanged;
  49. public TilePaletteBrushInspectorLockToggle()
  50. {
  51. name = "Tile Palette Brush Inspector Lock";
  52. AddToClassList(k_ToolSettingsClass);
  53. icon = EditorGUIUtility.LoadIconRequired("LockIcon");
  54. tooltip = k_TooltipText;
  55. }
  56. protected override void ToggleValue()
  57. {
  58. base.ToggleValue();
  59. ToggleChanged?.Invoke(value);
  60. }
  61. }
  62. }