IHandles.cs 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. using UnityEngine;
  2. using UnityHandles = UnityEditor.Handles;
  3. using UnityTexture2D = UnityEngine.Texture2D;
  4. namespace UnityEditor.U2D.Sprites
  5. {
  6. internal interface IHandles
  7. {
  8. Color color { get; set; }
  9. Matrix4x4 matrix { get; set; }
  10. Vector3[] MakeBezierPoints(Vector3 startPosition, Vector3 endPosition, Vector3 startTangent, Vector3 endTangent, int division);
  11. void DrawAAPolyLine(ITexture2D lineTex, float width, params Vector3[] points);
  12. void DrawAAPolyLine(ITexture2D lineTex, params Vector3[] points);
  13. void DrawLine(Vector3 p1, Vector3 p2);
  14. void SetDiscSectionPoints(Vector3[] dest, Vector3 center, Vector3 normal, Vector3 from, float angle, float radius);
  15. }
  16. internal class HandlesSystem : IHandles
  17. {
  18. static IHandles m_System;
  19. static public void SetSystem(IHandles system)
  20. {
  21. m_System = system;
  22. }
  23. static public IHandles GetSystem()
  24. {
  25. if (m_System == null)
  26. m_System = new HandlesSystem();
  27. return m_System;
  28. }
  29. public Color color
  30. {
  31. get { return UnityHandles.color; }
  32. set { UnityHandles.color = value; }
  33. }
  34. public Matrix4x4 matrix
  35. {
  36. get { return UnityHandles.matrix; }
  37. set { UnityHandles.matrix = value; }
  38. }
  39. public Vector3[] MakeBezierPoints(Vector3 startPosition, Vector3 endPosition, Vector3 startTangent, Vector3 endTangent, int division)
  40. {
  41. return UnityHandles.MakeBezierPoints(startPosition, endPosition, startTangent, endTangent, division);
  42. }
  43. public void DrawAAPolyLine(ITexture2D lineTex, float width, params Vector3[] points)
  44. {
  45. UnityHandles.DrawAAPolyLine((UnityTexture2D)lineTex, width, points);
  46. }
  47. public void DrawAAPolyLine(ITexture2D lineTex, params Vector3[] points)
  48. {
  49. UnityHandles.DrawAAPolyLine((UnityTexture2D)lineTex, points);
  50. }
  51. public void DrawLine(Vector3 p1, Vector3 p2)
  52. {
  53. UnityHandles.DrawLine(p1, p2);
  54. }
  55. public void SetDiscSectionPoints(Vector3[] dest, Vector3 center, Vector3 normal, Vector3 from, float angle, float radius)
  56. {
  57. UnityHandles.SetDiscSectionPoints(dest, center, normal, from, angle, radius);
  58. }
  59. }
  60. }