Can I call "Reload" in the script?
SkeletonDataAsset Reload
- Modifié
Sort of. But it's complicated.
What are you trying to do though? Maybe there's a better way to achieve it.
Sorry for the late response
I want to clear all player avatar mix and match.
But now I use "Nude.atlas" to reset it, I wonder know if there was a simpler way.
How you reset it depends on how you applied the mix and match.
If you want to revert to a previous/original skin, keep a reference to the original skin. And use skeletonAnimation.Skeleton.Skin = originalSkin;
You can also find all the skins you defined in Spine by using skeletonAnimation.Skeleton.Data.FindSkin("skin name");
. Make sure you don't overwrite them if you want to revert to them.
If you want to revert to having no skin, set skeletonAnimation.Skeleton.Skin = null;
If you want to be able to revert specific attachments, make sure you don't overwrite the actual original attachment data.
- Modifié
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!
Sorry for the late reply, but glad you figured it out! Thanks for letting us know!