I need to dress my character. When I attach the other attachment, the its mesh doesn't animate and just "hanging out" on the bone.
skeletonAnim1.skeleton.SetAttachment ("myFavouriteSlot", "workAttachment");//current attachment works normal
skeletonAnim1.skeleton.SetAttachment ("myFavouriteSlot", "otherAttachment"); //attachment changed but not animate (mesh)
At JSON file at animation specified workAttachment. I seem otherAttachment link to image need to change to image of work attachment .
skeletonAnim1.skeleton.SetAttachment ("myFavouriteSlot", "workAttachment");
RegionAttachment attOther = skeletonAnim1.skeleton.GetAttachment ("myFavouriteSlot", "otherAttachment") as RegionAttachment;
RegionAttachment attWork = skeletonAnim1.skeleton.FindSlot ("myFavouriteSlot").attachment as RegionAttachment;
attWork = attOther; // attachment view is not changed
The assignment of the current attachments to required attachments does not give effect.
What would you advise?
P.S. Sorry for my English. I'm not a native speaker.
20 Oct 2015, 13:18
My trouble solved by changing JSON file at runtime.
Create new field public string jsonText at class SkeletonDataAsset
Change method GetSkeletonData (show part of it):
try {
//var stopwatch = new System.Diagnostics.Stopwatch();
if (skeletonJSON.name.ToLower().Contains(".skel")) {
if (jsonText == null) jsonText = skeletonJSON.text;
var input = new MemoryStream(GetBytes(jsonText));
var binary = new SkeletonBinary(attachmentLoader);
binary.Scale = skeletonDataScale;
//stopwatch.Start();
skeletonData = binary.ReadSkeletonData(input);
} else {
if (jsonText == null)
jsonText = skeletonJSON.text;
var input = new StringReader(jsonText);
var json = new SkeletonJson(attachmentLoader);
json.Scale = skeletonDataScale;
//stopwatch.Start();
skeletonData = json.ReadSkeletonData(input);
}
Create method changeAttach and use it.
public void changeAttach(string attName, string slotName, int trackIndex, string currentAnimation, bool loop) {
skeletonAnim1.skeletonDataAsset.jsonText = skeletonAnim1.skeletonDataAsset.skeletonJSON.text.Replace (etalon, attName);
skeletonAnim1.skeletonDataAsset.GetSkeletonData (false);
skeletonAnim1.skeletonDataAsset.Reset ();
skeletonAnim1.Reset ();
skeletonAnim1.skeleton.SetAttachment (slotName, attName);
skeletonAnim1.state.SetAnimation (trackIndex, currentAnimation, loop);
}
Thanks for attention.