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.

TilePaletteMouseCursorUtility.cs 2.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. using UnityEngine;
  2. namespace UnityEditor.Tilemaps
  3. {
  4. internal class TilePaletteMouseCursorUtility
  5. {
  6. internal static class MouseStyles
  7. {
  8. // The following paths match the enums in OperatingSystemFamily
  9. public static readonly string[] mouseCursorOSPath =
  10. {
  11. "", // Other OS
  12. "Cursors/macOS",
  13. "Cursors/Windows",
  14. "Cursors/Linux",
  15. };
  16. // The following paths match the enums in OperatingSystemFamily
  17. public static readonly Vector2[] mouseCursorOSHotspot =
  18. {
  19. Vector2.zero, // Other OS
  20. new Vector2(6f, 4f),
  21. new Vector2(6f, 4f),
  22. new Vector2(6f, 4f),
  23. };
  24. // The following paths match the enums in sceneViewEditModes above
  25. public static readonly string[] mouseCursorTexturePaths =
  26. {
  27. "",
  28. "Grid.MoveTool.png",
  29. "Grid.PaintTool.png",
  30. "Grid.BoxTool.png",
  31. "Grid.PickingTool.png",
  32. "Grid.EraserTool.png",
  33. "Grid.FillTool.png",
  34. };
  35. public static readonly Texture2D[] mouseCursorTextures;
  36. public static readonly GridBrushBase.Tool[] sceneViewEditModes =
  37. {
  38. GridBrushBase.Tool.Select,
  39. GridBrushBase.Tool.Move,
  40. GridBrushBase.Tool.Paint,
  41. GridBrushBase.Tool.Box,
  42. GridBrushBase.Tool.Pick,
  43. GridBrushBase.Tool.Erase,
  44. GridBrushBase.Tool.FloodFill
  45. };
  46. static MouseStyles()
  47. {
  48. mouseCursorTextures = new Texture2D[mouseCursorTexturePaths.Length];
  49. int osIndex = (int)SystemInfo.operatingSystemFamily;
  50. for (int i = 0; i < mouseCursorTexturePaths.Length; ++i)
  51. {
  52. if ((mouseCursorOSPath[osIndex] != null && mouseCursorOSPath[osIndex].Length > 0)
  53. && (mouseCursorTexturePaths[i] != null && mouseCursorTexturePaths[i].Length > 0))
  54. {
  55. string cursorPath = Utils.Paths.Combine(mouseCursorOSPath[osIndex], mouseCursorTexturePaths[i]);
  56. mouseCursorTextures[i] = EditorGUIUtility.LoadRequired(cursorPath) as Texture2D;
  57. }
  58. else
  59. mouseCursorTextures[i] = null;
  60. }
  61. }
  62. }
  63. }
  64. }