Nenhuma descrição
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

GridPaintCreateTargetsDropdown.cs 2.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. using System;
  2. namespace UnityEditor.Tilemaps
  3. {
  4. internal class GridPaintCreateTargetsDropdown : FlexibleMenu
  5. {
  6. public static bool IsOpen = false;
  7. public GridPaintCreateTargetsDropdown(IFlexibleMenuItemProvider itemProvider, int selectionIndex, FlexibleMenuModifyItemUI modifyItemUi, Action<int, object> itemClickedCallback, float minWidth)
  8. : base(itemProvider, selectionIndex, modifyItemUi, itemClickedCallback)
  9. {
  10. minTextWidth = minWidth;
  11. }
  12. public override void OnOpen()
  13. {
  14. base.OnOpen();
  15. IsOpen = true;
  16. }
  17. public override void OnClose()
  18. {
  19. IsOpen = false;
  20. base.OnClose();
  21. }
  22. internal class MenuItemProvider : IFlexibleMenuItemProvider
  23. {
  24. private bool m_HasTilePalette;
  25. public MenuItemProvider(bool hasTilePalette)
  26. {
  27. m_HasTilePalette = hasTilePalette;
  28. }
  29. public int Count()
  30. {
  31. return GameObjectCreation.CreateTilemapTargetsNames.Length - (m_HasTilePalette ? 0 : 1);
  32. }
  33. public object GetItem(int index)
  34. {
  35. if (!m_HasTilePalette)
  36. index += 1;
  37. if (index < GameObjectCreation.CreateTilemapTargetsNames.Length)
  38. return GameObjectCreation.CreateTilemapTargetsNames[index];
  39. return null;
  40. }
  41. public int Add(object obj)
  42. {
  43. throw new NotImplementedException();
  44. }
  45. public void Replace(int index, object newPresetObject)
  46. {
  47. throw new NotImplementedException();
  48. }
  49. public void Remove(int index)
  50. {
  51. throw new NotImplementedException();
  52. }
  53. public object Create()
  54. {
  55. throw new NotImplementedException();
  56. }
  57. public void Move(int index, int destIndex, bool insertAfterDestIndex)
  58. {
  59. throw new NotImplementedException();
  60. }
  61. public string GetName(int index)
  62. {
  63. if (!m_HasTilePalette)
  64. index += 1;
  65. if (index < GameObjectCreation.CreateTilemapTargetsNames.Length)
  66. return GameObjectCreation.CreateTilemapTargetsNames[index];
  67. return "";
  68. }
  69. public bool IsModificationAllowed(int index)
  70. {
  71. return false;
  72. }
  73. public int[] GetSeperatorIndices()
  74. {
  75. return Array.Empty<int>();
  76. }
  77. }
  78. }
  79. }