FreeformPathPresets.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. using UnityEngine;
  2. namespace UnityEditor.Rendering.Universal
  3. {
  4. internal static class FreeformPathPresets
  5. {
  6. public static Vector3[] CreateSquare()
  7. {
  8. Vector3[] returnPath = new Vector3[4]
  9. {
  10. new Vector3(-0.5f, -0.5f),
  11. new Vector3(0.5f, -0.5f),
  12. new Vector3(0.5f, 0.5f),
  13. new Vector3(-0.5f, 0.5f)
  14. };
  15. return returnPath;
  16. }
  17. public static Vector3[] CreateIsometricDiamond()
  18. {
  19. Vector3[] returnPath = new Vector3[4]
  20. {
  21. new Vector3(-0.5f, 0.0f),
  22. new Vector3(0.0f, -0.25f),
  23. new Vector3(0.5f, 0.0f),
  24. new Vector3(0.0f, 0.25f)
  25. };
  26. return returnPath;
  27. }
  28. private static Vector3[] CreateShape(int vertices, float angleOffset)
  29. {
  30. Vector3[] returnPath = new Vector3[vertices];
  31. const float kRadius = 0.5f;
  32. for (int i = 0; i < vertices; i++)
  33. {
  34. float angle = ((float)i * 2 * Mathf.PI / (float)vertices) + angleOffset;
  35. float x = kRadius * Mathf.Cos(angle);
  36. float y = kRadius * Mathf.Sin(angle);
  37. returnPath[i] = new Vector3(x, y);
  38. }
  39. return returnPath;
  40. }
  41. public static Vector3[] CreateCircle()
  42. {
  43. return CreateShape(32, 0);
  44. }
  45. public static Vector3[] CreateHexagonFlatTop()
  46. {
  47. return CreateShape(6, 0);
  48. }
  49. public static Vector3[] CreateHexagonPointedTop()
  50. {
  51. return CreateShape(6, 0.5f * Mathf.PI);
  52. }
  53. }
  54. }