FlexibleGrid.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. using Assets;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. using UnityEngine.UI;
  6. namespace Bitsplash.Vector
  7. {
  8. public class FlexibleGrid : MaskableGraphic , DatePicker.IDatePickerSettingsItem
  9. {
  10. [SerializeField]
  11. [HideInInspector]
  12. private bool isOpen;
  13. public string EditorTitle { get { return gameObject.name; } }
  14. public int Order { get { return 1; } }
  15. public int TotalColumns = 7;
  16. public int TotalRows = 6;
  17. public float ColumnLineThickness = 2f;
  18. public float RowLineThickness = 2f;
  19. public float TextureTile = 1f;
  20. protected override void OnPopulateMesh(VertexHelper vh)
  21. {
  22. vh.Clear();
  23. var rect = GetPixelAdjustedRect();
  24. Rect xRect = CommonMethods.VerticalTextureTile(TextureTile);
  25. for (int i = 1; i < TotalColumns; i++)
  26. {
  27. float factor = ((float)i) / (float)TotalColumns;
  28. float x = CommonMethods.InterpolateInRectX(factor, rect);
  29. CommonMethods.DrawVertical(x, rect, ColumnLineThickness, xRect, color, vh);
  30. }
  31. Rect yRect = CommonMethods.HorizontalTextureTile(TextureTile);
  32. for (int i = 1; i < TotalRows; i++)
  33. {
  34. float factor = ((float)i) / (float)TotalRows;
  35. float y = CommonMethods.InterpolateInRectY(factor, rect);
  36. CommonMethods.DrawHorizontal(y, rect, RowLineThickness, yRect, color, vh);
  37. }
  38. }
  39. }
  40. }