I need to remove the duplicates of elements in my Vector3 list. For Example, here is a list:
List<Vector3> PointsToGo = new List<Vector3>();
PointsToGo.Add(new Vector3(1, 1, 1));
PointsToGo.Add(new Vector3(2, 2, 2));
PointsToGo.Add(new Vector3(1, 1, 1)); // Get this one or the first one out
PointsToGo.Add(new Vector3(4, 4, 4));
Do you know how to solve this problem ? Maybe Linq can help me ?
Thanks for your answer!
Here is your solution
PointsToGo = PointsToGo.Distinct().ToList();
Note that you have add using System.Linq; to the top your code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With