The type 'UnityEngine.Vector2' must be convertible to 'System.IComparable<UnityEngine.Vector2>' to use it as parameter 'T' in generic class Graph<T>

153 views Asked by At

error message

I don't understand, How can I solve this problem?

1

There are 1 answers

0
JamesFaix On

It looks like you are running into an issue with constraints on generic type parameters in C#.

You are trying to create a Graph<Vector2>, but Graph<T> can only be used with generic types that implement the IComparable<T> interface. This is probably because the implementation of Graph uses < or > to compare the value of two nodes of the graph.