Suggestion: Add more sorting options to OdinMenuTree
Hello,
My designer has been bugging me to add some way to sort RPG items and characters by their member variables within our editors. Currently, the only sorting I've seen usable is OdinMenuTree.SortMenuItemsByName(), which is nice for a lot of cases, but our team needs a bit more control while iterating over RPG items & such.
Initially I reached for a lambda expression like what follows:
myList.Sort(characters, c => c.Strength, SortOrder.Ascending);
using the same pattern as in this article https://www.c-sharpcorner.com/UploadFile/afenster/lambda-expressions-are-wonderful/, but quickly I realized that OdinMenuTree.AddAllAssetsAtPath wouldn't afford me the control I need over the lists as it just kinda dumps everything in within the path.
Would it be possible to control the order of assets added to a tree or subtree by perhaps adding another overload to OdinMenuTree.AddAllAssetsAtPath, precisely at that step? Or is there a workaround I'm not currently seeing with OdinMenuItem?
Thanks.
Comments (3)
-
-
- changed status to resolved
-
reporter That should all be possible, everything should be exposed in order for you to do it a manually :)
Thanks so much for the clarification!
- Log in to comment
That should all be possible, everything should be exposed in order for you to do it a manually :)
In its basic form, OdinMenuItems just looks like this: so from that, you can easily just sort the list of ChildMenuItems yourself.
And calling AddAllAssetsAtPath does what you would expect, but it also returns all menu items it added. Which means you can do: