To reload the SkeletonDataAsset
at runtime, you can use the following approach in your script:
- Assign the new
SkeletonDataAsset
to your SkeletonAnimation
or SkeletonGraphic
component.
- Call the
Initialize(true)
method to reinitialize the skeleton with the new data.
Here is an example of how you can do this:
public SkeletonDataAsset newSkeletonDataAsset;
void ReloadSkeletonDataAsset() {
SkeletonAnimation skeletonAnimation = this.GetComponent<SkeletonAnimation>();
skeletonAnimation.skeletonDataAsset = newSkeletonDataAsset;
skeletonAnimation.Initialize(true);
}
In this example, newSkeletonDataAsset
is the new SkeletonDataAsset
you want to load. The Initialize(true)
method will reinitialize the skeleton with the new data, effectively reloading it.
Additionally, make sure to set the initialSkinName
and AnimationName
to values that exist in the new SkeletonDataAsset
before calling Initialize(true)
if necessary.
If you are encountering issues with the rotation of the mesh after removing the ragdoll, reinitializing the skeleton as shown above should help reset the skeleton to its default state.
If you continue to experience issues, please ensure that the new SkeletonDataAsset
is correctly set up and that all necessary references are updated.