Dictionary<TKey, TValue> Support in Tri Inspector (Prototype) #209
Replies: 4 comments
-
|
I came across this older discussion (#116) while working on this prototype. Since that thread is from 2023, I wanted to ask what the current stance is regarding this topic and whether there are any plans or openness to this kind of functionality today. For context: I’m using the standalone Odin Serializer downloaded from Before continuing and preparing something that could eventually become a PR, I’d like to know if support for Odin-serialized types is something you would consider, or if this should remain strictly as an external extension. |
Beta Was this translation helpful? Give feedback.
-
|
Tri Inspector was made as an editor extension on top of Unity's built-in serialization, and I want to keep it that way, as adding support for custom types requires both a significant increase of the library's architecture and the implementation of a custom serializer. Regarding the Odin Serializer, I don't think integrating it into Tri Inspector is the right decision. Therefore, the preferred way to implement support for custom types is through an external extension. I'm ready to discuss and merge changes to Tri Inspector if something will be needed to develop such an extension (if those changes aren't too complex). |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
|
Thanks a lot for the feedback, @vanifatovvlad, and also thanks to @TylerTemp for the insights! After taking another look, I agree that integrating a custom serializer directly into the Tri-Inspector core is probably not the best path. The added complexity and long-term maintenance risks are very real, and keeping Tri focused on Unity’s native serialization makes a lot of sense. I also took a look at SaintsField and, even from a quick overview, I was really impressed by how robust it looks. I’ll probably test it soon and there’s a good chance I’ll adopt it as one of my core packages alongside Tri-Inspector. Really appreciate all the opinions shared here. Thanks again! |
Beta Was this translation helpful? Give feedback.


Uh oh!
There was an error while loading. Please reload this page.
-
I'm experimenting with a prototype to add
Dictionary<TKey, TValue>support to Tri Inspector using only Odin Serializer. The goal also started with supporting more complex types (HashSet,Queue, basically anything Odin Serializer can handle).I'm still unsure if bringing Odin Serializer into the project is a good long-term idea, but for now it felt like the most practical way to explore this.
The drawer follows the style of Tri Inspector’s built-in drawers. I used the
TableListattribute as inspiration to display dictionaries as a clean Key/Value table.The drawer is registered via:
[assembly: RegisterTriValueDrawer(typeof(DictionaryDrawer<,>), TriDrawerOrder.Drawer)]and I had to adjust
TriDrawersUtilitiesto support composite generic drawers.About serialization
Just like in Odin Inspector, you can simply inherit from
SerializedMonoBehaviourto get automatic serialization.As an alternative, I implemented a small weaver that injects the required serialization code directly into the assembly.
With this weave, you can mark a class or an individual field with
[TriSerialize], and the system automatically injects implementations ofISerializationCallbackReceiverandISupportsPrefabSerialization, similar to howSerializedMonoBehaviourworks.In my initial tests, the data persists correctly after domain reloads and scene reloads.
This is still only a prototype, the code needs cleanup, review, and more thorough testing. For now, I'm just exploring options and seeing how this could integrate naturally with Tri Inspector.
Examples:
Beta Was this translation helpful? Give feedback.
All reactions