int GetClosestEdgePointToPosition(Vector3 _position, float _pickSize, ref Vector3 _outVector) { Vector3 pnt = new Vector3(); float pDist = Mathf.Infinity; int index = -1; for (int i = 0; i < edges.arraySize; i++) { Vector2 pntA = edges.GetArrayElementAtIndex(i).FindPropertyRelative("pointA").FindPropertyRelative("position").vector3Value; Vector2 pntB = edges.GetArrayElementAtIndex(i).FindPropertyRelative("pointB").FindPropertyRelative("position").vector3Value; Vector2 norm = edges.GetArrayElementAtIndex(i).FindPropertyRelative("normal").vector3Value; if (VLSUtility.LineIntersects(_position - (Vector3)(norm * _pickSize), _position + (Vector3)(norm * _pickSize), pntA, pntB, ref pnt)) { if (Vector3.SqrMagnitude(pnt - _position) < pDist) { pDist = Vector3.SqrMagnitude(pnt - _position); _outVector = pnt; index = i; } } } return((index + 1) % edges.arraySize); }
public override void UpdateVertices() { VLSUtility.GenerateRadialMesh(this, shadowLayer); }