You have to set initialSkinName
, otherwise it will be a remainder of the previously set skin name that is causing an error during Initialize()
, looking for the old skin name.
In the case of SkeletonGraphic, you also have to be sure to update the MaskableGraphic part via SetMaterialDirty()
.
The relevant code is as follows:
skeletonGraphic.initialSkinName = "goblin";
skeletonGraphic.startingAnimation = "";
skeletonGraphic.Initialize(true);
skeletonGraphic.AnimationState.SetAnimation(0, "walk", true);
skeletonGraphic.SetMaterialDirty();