CircleVertexSelector.cs 780 B

12345678910111213141516171819202122232425262728
  1. using UnityEngine;
  2. namespace UnityEditor.U2D.Animation
  3. {
  4. internal class CircleVertexSelector : ICircleSelector<int>
  5. {
  6. public ISelection<int> selection { get; set; }
  7. public ISpriteMeshData spriteMeshData { get; set; }
  8. public Vector2 position { get; set; }
  9. public float radius { get; set; }
  10. public void Select()
  11. {
  12. if(spriteMeshData == null)
  13. return;
  14. var sqrRadius = radius * radius;
  15. for (int i = 0; i < spriteMeshData.vertexCount; i++)
  16. {
  17. if ((spriteMeshData.GetPosition(i) - position).sqrMagnitude <= sqrRadius)
  18. {
  19. selection.Select(i, true);
  20. }
  21. }
  22. }
  23. }
  24. }