Adding a second value to a HashSet<(Vector2, Vector2)>breaks Odin editor.

Issue #838 new
Eduardo Freire created an issue

Adding a second value to a HashSet<(Vector2, Vector2)>breaks Odin editor.
with:

ArgumentException: At least one object must implement IComparable. 

Just create this class with and add two entries on the HashSet in Inspector (or by code)

public class HashSetTest : SerializedMonoBehaviour 
{ 
    [ShowInInspector] private HashSet<(Vector2, Vector2)> hashset;
} 

The problem occurs with (Vector2, Vector2), (Vector3, Vector3), (Quaternion, Quaternion). Tested with (int, int) and got no problems.

Also, this only occurs in Odin. Just not having the ShowInInspector (or not having the gameobject with this component selected/showing is enough to keep the exception from happening.

Odin Version tested: 3.0.12.0 and 3.0.5.0

Unity Version 2021.1.10f1
Windows 11

Stack trace:

ArgumentException: At least one object must implement IComparable.
Rethrow as InvalidOperationException: Failed to compare two elements in the array.
Rethrow as OdinPropertyException: This error occurred while being drawn by Odin.
Current IMGUI event: Layout
Odin Property Path: selectedPoints
Odin Drawer Chain:
PropertyContextMenuDrawer<HashSet<ValueTuple<Vector2, Vector2>>>
ReferenceDrawer<HashSet<ValueTuple<Vector2, Vector2>>>
FixUnityNullDrawer<HashSet<ValueTuple<Vector2, Vector2>>>
NonSerializedShowInInspectorWarningAttributeDrawer
NullableReferenceDrawer<HashSet<ValueTuple<Vector2, Vector2>>>
CollectionDrawer<HashSet<ValueTuple<Vector2, Vector2>>>
CompositeDrawer.

Comments (1)

  1. Antonio Rafael Antunes Miranda

    Create a BaseDictionaryKeyPathProvider<T> for your Tuple and register it using [assembly: Sirenix.Serialization.RegisterDictionaryKeyPathProvider(typeof(MyKeyPathProvider)]. 🙂

  2. Log in to comment