I can’t seem to find any documentation or tutorials on how to use Tree View. I’ve found some UE4 tutorials on Tree View, but the widget seems to have been refactored in UE5 and I can’t find any equivalent events. The widget doesn’t seem to have been deprecated far as I can find.
I could maybe use List View to create similar functionality, but I’d like to understand how Tree View works.
This doesn’t help me. As I mentioned, the functionality has been refactored in UE5 and many of those interface functions and events don’t exist anymore.
I’ve found blueprint api references in the UE5 docs that aren’t marked as deprecated, so I’m leaning yes. But this hasn’t been the first time their documentation was wrong about something.
I have used and worked with both tree view and list view extensively and I can tell you that, in my opinion, Tree View is not worth the effort.
Here are several limitations the Tree View suffers from that List Views do not:
You have to manage all navigation for a tree view. Do you want navigation like you get in Windows Explorer? That is much more complicated than List View as there is no built-in navigation. Here is an example of my Next routine. Not the end of the world, but it has finicky complexity - meaning when you are developing yours expect to struggle getting the logic correct. Each of these pure methods are somewhat complex as well, but I will get to that.
Next, you know how you need to wrap your ListView candidate in an object? Well in my game most everything already derives from UObject. This makes them perfect candidates for ListView directly. But not for Tree. You see, Tree objects need to understand their relationship hierarchy as in a very different way. If you are like me, you already have your objects related to each other hierarchically so you might think “Perfect, my stuff will naturally just work for a tree!” However like me, that might not be the case. You see your objects might be structured hierarchically, but do they have tree navigation in mind? Remember that complex navigation scheme? You will need to encode that in every hierarchy over and over, unless you make a TreeObject type of wrapper (which is what I did). Even though I am proud of the work for my Tree wrapper system, I find it very cumbersome to use and get confused every time I implement it.
So after spending several long days over the past two months coding different aspects of this for similar needs in my game I have come to the following conclusion:
Most “Here is how you use a tree” are simple 1, 2, 3 nested lists that do not even closely represent real-world situations making them virtually useless when you implement one yourself in a game. If you need a simple 1,2,3 nested tree then you will not find them difficult to use.
Once you go through the pains of giving birth to your tree, it works very well if the hierarchical data in it is not volatile. Like anything complex, once you solve it then it will work forever.
If you have serious tree depth or the relationships change frequently, I recommend using a nest List View approach instead. It is super easy to use and since you are only rendering one level at a time volatility is never an issue.
If you still want to use a tree and would like more specific help on implementing navigation I would be happy to provide more detailed BP examples that fit a more real-world approach and not the simple 1,2,3.
Update: Looking at the @LenSolla post above, his tutorial is amazing. Highly detailed and a real-world example that goes into great detail. Really nice work.
Additional Update: It turns out that my object hierarchy re-stitching issue was a bug on my part. When an object hierarchy changed I was failing to clear the child reference from its old parent resulting in bad navigation references. After fixing that I find that and requesting a refresh on the tree to account for the changes it works as expected.