Old thread, but I'd like to do what was asked in the original question - I'd like to essentially "Press the Reload button" for multiple SkeletonAnimations when I press a single button in a custom inspector I made.
Here is what I'm trying to do:
I have a character that has multiple views (front & back) which are separate SkeletonAnimations.
I have a setup where I can run the game, and test out different "attacks" that the character does by pressing buttons in a custom inspector.
I want to be able to look at the mixing that is done during an "attack", and then add/modify a Custom Mix Duration on the SkeletonData asset for that character.
Then I'd like to press that button in my custom inspector to do 2 things:
1) "Press the Reload button" for both the front and back SkeletonAnimation so that it now shows the updated Custom Mix Duration.
2) Re-set (fix the link) my custom Root Motion script, which gets broken after pressing the "Reload" button.
I'm trying to look through the code to see how to essentially press that "Reload" button, so I might be able to accomplish this myself, but figured I'd ask in case there is anything special I need to do. If I figure it out myself I'll post an update :grinteeth:
Alright I think I may have gotten part 1 done - I basically set up an custom version of this section of code from the SkeletonRendererInspector :
Edit: the code below is no longer needed, you can now just make a call to: SpineEditorUtilities.ReloadSkeletonDataAssetAndComponent
static void EditorForceReloadSkeletonDataAssetAndComponent (SkeletonRenderer component) {
if (component == null) return;
// Clear all and reload.
if (component.skeletonDataAsset != null) {
foreach (AtlasAssetBase aa in component.skeletonDataAsset.atlasAssets) {
if (aa != null) aa.Clear();
}
component.skeletonDataAsset.Clear();
}
component.skeletonDataAsset.GetSkeletonData(true);
// Reinitialize.
EditorForceInitializeComponent(component);
}
static void EditorForceInitializeComponent (SkeletonRenderer component) {
if (component == null) return;
if (!SkeletonDataAssetIsValid(component.SkeletonDataAsset)) return;
component.Initialize(true);
#if BUILT_IN_SPRITE_MASK_COMPONENT
SpineMaskUtilities.EditorAssignSpriteMaskMaterials(component);
#endif
component.LateUpdate();
}
static bool SkeletonDataAssetIsValid (SkeletonDataAsset asset) {
return asset != null && asset.GetSkeletonData(quiet: true) != null;
}
Now just need to fix up the Root Motion getting lost when its reloaded 🙂
Ok, just need to basically call "Start()" again on the RootMotion script to link it back up after the SkeletonAnimation has been reloaded. Think I'm good to go!