testss
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityEditor.U2D.Animation
|
||||
{
|
||||
internal class CircleVertexSelector : ICircleSelector<int>
|
||||
{
|
||||
public ISelection<int> selection { get; set; }
|
||||
public ISpriteMeshData spriteMeshData { get; set; }
|
||||
public Vector2 position { get; set; }
|
||||
public float radius { get; set; }
|
||||
|
||||
public void Select()
|
||||
{
|
||||
if(spriteMeshData == null)
|
||||
return;
|
||||
|
||||
var sqrRadius = radius * radius;
|
||||
|
||||
for (int i = 0; i < spriteMeshData.vertexCount; i++)
|
||||
{
|
||||
if ((spriteMeshData.GetPosition(i) - position).sqrMagnitude <= sqrRadius)
|
||||
{
|
||||
selection.Select(i, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityEditor.U2D.Animation
|
||||
{
|
||||
internal class GenericVertexSelector : ISelector<int>
|
||||
{
|
||||
public ISelection<int> selection { get; set; }
|
||||
public ISpriteMeshData spriteMeshData { get; set; }
|
||||
public Func<int, bool> SelectionCallback;
|
||||
|
||||
public void Select()
|
||||
{
|
||||
Debug.Assert(selection != null);
|
||||
Debug.Assert(spriteMeshData != null);
|
||||
Debug.Assert(SelectionCallback != null);
|
||||
|
||||
for (var i = 0; i < spriteMeshData.vertexCount; i++)
|
||||
selection.Select(i, SelectionCallback(i));
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,9 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityEditor.U2D.Animation
|
||||
{
|
||||
internal interface ICircleSelector<T> : ISelector<T>
|
||||
{
|
||||
float radius { get; set; }
|
||||
}
|
||||
}
|
@@ -0,0 +1,9 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityEditor.U2D.Animation
|
||||
{
|
||||
internal interface IRectSelector<T> : ISelector<T>
|
||||
{
|
||||
Rect rect { get; set; }
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace UnityEditor.U2D.Animation
|
||||
{
|
||||
internal interface ISelector<T>
|
||||
{
|
||||
ISelection<T> selection { get; set; }
|
||||
|
||||
void Select();
|
||||
}
|
||||
}
|
@@ -0,0 +1,35 @@
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace UnityEditor.U2D.Animation
|
||||
{
|
||||
internal class RectBoneSelector : IRectSelector<BoneCache>
|
||||
{
|
||||
public ISelection<BoneCache> selection { get; set; }
|
||||
public BoneCache[] bones { get; set; }
|
||||
public Rect rect { get; set; }
|
||||
|
||||
public void Select()
|
||||
{
|
||||
if (bones == null)
|
||||
return;
|
||||
|
||||
foreach (var bone in bones)
|
||||
{
|
||||
if (!bone.isVisible)
|
||||
continue;
|
||||
|
||||
Vector2 p1 = bone.position;
|
||||
Vector2 p2 = bone.endPosition;
|
||||
Vector2 point = Vector2.zero;
|
||||
if (rect.Contains(p1, true) || rect.Contains(p2, true) ||
|
||||
MathUtility.SegmentIntersection(new Vector2(rect.xMin, rect.yMin), new Vector2(rect.xMax, rect.yMin), p1, p2, ref point) ||
|
||||
MathUtility.SegmentIntersection(new Vector2(rect.xMax, rect.yMin), new Vector2(rect.xMax, rect.yMax), p1, p2, ref point) ||
|
||||
MathUtility.SegmentIntersection(new Vector2(rect.xMax, rect.yMax), new Vector2(rect.xMin, rect.yMax), p1, p2, ref point) ||
|
||||
MathUtility.SegmentIntersection(new Vector2(rect.xMin, rect.yMax), new Vector2(rect.xMin, rect.yMin), p1, p2, ref point)
|
||||
)
|
||||
selection.Select(bone.ToCharacterIfNeeded(), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,21 @@
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace UnityEditor.U2D.Animation
|
||||
{
|
||||
internal class RectVertexSelector : IRectSelector<int>
|
||||
{
|
||||
public ISelection<int> selection { get; set; }
|
||||
public ISpriteMeshData spriteMeshData { get; set; }
|
||||
public Rect rect { get; set; }
|
||||
|
||||
public void Select()
|
||||
{
|
||||
for (int i = 0; i < spriteMeshData.vertexCount; i++)
|
||||
{
|
||||
if (rect.Contains(spriteMeshData.GetPosition(i), true))
|
||||
selection.Select(i, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,14 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityEditor.U2D.Animation
|
||||
{
|
||||
internal class Unselector<T> : ISelector<T>
|
||||
{
|
||||
public ISelection<T> selection { get; set; }
|
||||
|
||||
public void Select()
|
||||
{
|
||||
selection.Clear();
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user