我需要从向量列表中返回较小的vector3,例如: var positions = new ListVector3();positions.Add(new Vector3(135, 125, 13));positions.Add(new Vector3(55, 12, 13));positions.Add(new Vector3(1353, 346, 13));positions.Add(new Vector
var positions = new List<Vector3>(); positions.Add(new Vector3(135, 125, 13)); positions.Add(new Vector3(55, 12, 13)); positions.Add(new Vector3(1353, 346, 13)); positions.Add(new Vector3(1442, 979, 134)); private Vector3 SmallerPosition(List<Vector3> positions) { positions.Sort(); return positions[0]; } Debug.Log(SmallerPosition(positions));
但我知道这是不可能的,所以,我怎样才能做到这一点?
使用linq.positions.OrderBy(v => v.sqrMagnitude).First();