Open NPatch opened 9 months ago
Switched to draft because I noticed an issue with the IMGUI version not showing the correct AnimRetargetData when it's a preset.
Did you ever look at AnimationUtility class? Specifically AnimationUtility.GetCurveBindings and AnimationUtility.GetEditorCurve and SetEditorCurve.
Path and Attribute names are given in the EditorCurveBinding class which can be altered through SetEditorCurve.
I'm thinking you don't have to do straight up SerializedProperty lookups with .Next etc.
There are two issues with the package currently. 1) In newer versions AnimationRetargetingData does not persist when manipulated by the EditorWindow (#1) 2) Newer Unity versions have converted to UI Toolkit mostly (or are in the process).
About 1), not entirely sure how it happened. Usually you call serializedObject.Update in the start of OnGUI and ApplyModifiedProperties at the end. I know that you technically create the serializedObject every time so it's akin to Update, but somehow the changes made within the Drawers were not communicated back from the Drawers to the serializedObject in order to actually ApplyModifiedProperties. To counter that, we Update and Apply within each Drawer and also in the EditorWindow's OnGUI.
For 2), created a UI Toolkit version of the tool. Tried to reuse as much as possible.
To allow for backwards compatibility, there's some use of preprocessor conditionals. By default it uses the IMGUI version, but whoever wishes can switch to the UI Toolkit version by adding the ANIMATION_RETARGETING_UTILITY_UITOOLKIT definition in Project Settings -> Scripting Define Symbols.
Let me know what you think about this.