-
Notifications
You must be signed in to change notification settings - Fork 25
Description
Description
Unity 6000.2 updated the TreeView API and this package no longer works.
The HierarchyFolderIcon class is where the problems arise. Before the update this line worked properly:
prop_data = type_treeViewController.GetProperty("data", BindingAll);
But after the update this results in an Ambiguous match found error. This happens because Unity 6000.2 introduced a generic TreeViewItem type. I tried to get it working and managed in the end but it's not very nice:
I use this code to get prop_data instead so I get the generic type:
prop_data = type_treeViewController.GetProperties(BindingAll)
.First(p => p.Name == "data" && p.PropertyType.IsGenericType);
Then I got rid of the meth_getRows and meth_isExpanded related code:
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "Special naming scheme")]
private static MethodInfo meth_getRows;
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "Special naming scheme")]
private static MethodInfo meth_isExpanded;
...
var type_iTreeViewDataSource = assembly.GetType("UnityEditor.IMGUI.Controls.ITreeViewDataSource");
meth_getRows = type_iTreeViewDataSource.GetMethod("GetRows");
meth_isExpanded = type_iTreeViewDataSource.GetMethod("IsExpanded", new Type[] { typeof(TreeViewItem) });
And then I get the methods in the RefreshFolderIcons function itself:
var rows = (IList<TreeViewItem<int>>)data.GetType().GetMethod("GetRows").Invoke(data, Array.Empty<object>());
...
bool isExpanded = (bool)data.GetType().GetMethods().First(p => p.Name == "IsExpanded").Invoke(data, new object[] { item.id });
It now uses the new generic API but it might be worse for performance since I get the methods every time RefreshFolderIcons is called. Ideally there would be a proper fix.
Great package by the way, thanks!
Environment
- Unity 6000.2.5
- Windows 10