A game about forced loneliness, made by TACStudios
at master 34 lines 1.4 kB view raw
1using UnityEngine; 2 3namespace UnityEditor.U2D.Animation 4{ 5 internal class RectBoneSelector : IRectSelector<BoneCache> 6 { 7 public ISelection<BoneCache> selection { get; set; } 8 public BoneCache[] bones { get; set; } 9 public Rect rect { get; set; } 10 11 public void Select() 12 { 13 if (bones == null) 14 return; 15 16 foreach (var bone in bones) 17 { 18 if (!bone.isVisible) 19 continue; 20 21 Vector2 p1 = bone.position; 22 Vector2 p2 = bone.endPosition; 23 Vector2 point = Vector2.zero; 24 if (rect.Contains(p1, true) || rect.Contains(p2, true) || 25 MathUtility.SegmentIntersection(new Vector2(rect.xMin, rect.yMin), new Vector2(rect.xMax, rect.yMin), p1, p2, ref point) || 26 MathUtility.SegmentIntersection(new Vector2(rect.xMax, rect.yMin), new Vector2(rect.xMax, rect.yMax), p1, p2, ref point) || 27 MathUtility.SegmentIntersection(new Vector2(rect.xMax, rect.yMax), new Vector2(rect.xMin, rect.yMax), p1, p2, ref point) || 28 MathUtility.SegmentIntersection(new Vector2(rect.xMin, rect.yMax), new Vector2(rect.xMin, rect.yMin), p1, p2, ref point) 29 ) 30 selection.Select(bone.ToCharacterIfNeeded(), true); 31 } 32 } 33 } 34}