Fix theme access and improve UX in AnimationTree editor #82210
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #81966. Fixes #82014.
This PR fixes an assortment of issues related to the AnimationTree editor and its subeditors. First of all, it fixes the aforementioned bugs (one of which is tangentially related, but can be reproduced in the same workflow, so I grabbed it along the way).
Theming issues
To properly fix the issue with the theme access I decided to do a proper cleanup and organize all the styles used by the state machine editor into their own type in the editor theme. As well as implement proper caching and bind used theme properties, for the first time in the editor codebase! At the core of the regression was the fact that animation editors used borrowed styles from
GraphEdit
andGraphNode
, which were recently remade. And thus this fragile reliance was severed.Having a proper pre-configured type helps to avoid such issues in the future, even if internally we still borrow styles. It also allows to clearly define what the state machine graph needs to be rendered. For example, the
GraphNode
rework removed one of the styles that only the state machine graph used, because that wasn't obvious. AlsoGraphNode
in the editor had definitions which aren't related to that node at all, and that's not great.Before
After
I also enabled antialiasing on the transition lines, it looks better and I don't think it would be too taxing.
More issues
Along the way I tried to improve some related code. This was mostly to make it cleaner and clearer, but there were also mistakes. Namely, we were sorting an empty array of possible class names, and only then populated it with data. That's probably not what the author has intended. Fixed now, but that means that classes in the context menu are now actually ordered.
In that same context menu we weren't properly handling the case when there was no animation player connect, or the animation player had no animations. I reworked the code to disable the submenu in this case:
I used the opportunity to also add tooltips to buttons rendered in the state machine graph. All the scaffolding for this was already in place, I just cleaned it up and utilized.
And then there was an error spam issue when selecting the tree root of an animation tree. It happened if you already have a BlendSpace1D or BlendSpace2D class selected, and then clicked on the resource picker's popup button. The issue here was with the check in getters of those classes. We reported errors when accessing blend points that haven't been formally added yet. But those points did exist as valid properties, which we would try to access as a part of some resource picker logic. So those getters would trigger for each one of them and print a bunch of errors.
I changed the index check from the number of used points to the maximum number of points. All unused points should still be initialized and return proper default values, and errors don't seem to be useful here.