ara

Hi, thanks for the neat API, I can combine multiple skins during runtime like this:
public void CombineSkinForSingleSA()
{
if (skinNameList.Count != 0)
{
tempCombineSkin = new Skin("combinedSkin");
for (int i = 0; i < skinNameList.Count; i++)
{
Skin foundSkin = sa.Skeleton.Data.FindSkin(skinNameList[i]);
if (foundSkin != null)
tempCombineSkin.AddAttachments(foundSkin);
}

sa.Skeleton.SetSkin(tempCombineSkin);
sa.Skeleton.SetSlotsToSetupPose();
sa.AnimationState.Apply(sa.Skeleton);
}
}
However my artist ask me to preview/show multiple skins in unity editor today. :think:
I make a litte script with [ExecuteInEditMode] tag.
But after call the combine function, the combined skin will only stay in a few moment then back to initial state when lose focus(select other GameObject in editor) .
Is there some mechanism trying to reset the whole skelenAnimationComp?
Is it possible to keep the multiple skins editor preview result?
Thanks! :D
Hình đại diện của thành viên
ara
  • Bài viết: 56

Harald

Glad that you like the API!

You should be able to prevent any overrides by subscribing to the skeletonRenderer.OnRebuild delegate and calling your SetCustomCombinedSkin method in the callback method:
spine-runtimes/SkeletonRenderer.cs at 3.8
This callback hook will be called after any initialization methods which will reset the skin to the Initial Skin Name skin.

---

We also have this ticket on our roadmap to support it out of the box:
[unity] Provide component interface to set combined skins · #1633
Hình đại diện của thành viên
Harald

Harri
  • Bài viết: 1951

ara

Harald đã viết:Glad that you like the API!

You should be able to prevent any overrides by subscribing to the skeletonRenderer.OnRebuild delegate and calling your SetCustomCombinedSkin method in the callback method:
spine-runtimes/SkeletonRenderer.cs at 3.8
This callback hook will be called after any initialization methods which will reset the skin to the Initial Skin Name skin.

---

We also have this ticket on our roadmap to support it out of the box:
[unity] Provide component interface to set combined skins · #1633
Thanks Harald!
I tried OnRebuild but it's not called.
Could you please take a look at my script :think:
Bạn không được cấp phép để xem tập tin đính kèm trong bài viết này.
Hình đại diện của thành viên
ara
  • Bài viết: 56

Harald

Sorry to hear that it didn't solve the problem. I will have a look at it tomorrow and get back to you as soon as I figured it out.
Hình đại diện của thành viên
Harald

Harri
  • Bài viết: 1951

ara

Ok. Thanks! :D
Hình đại diện của thành viên
ara
  • Bài viết: 56

Harald

I just discovered that I recommended the wrong method, I misremembered what the proper solution was, sorry about that.

The proper way is to set skeletonRenderer.EditorSkipSkinSync = true, as described in this posting:
Dynamic Attachments Showing in Editor
This prevents the SkeletonRenderer Inspector from calling the respective code parts in UpdateIfSkinMismatch.
Hình đại diện của thành viên
Harald

Harri
  • Bài viết: 1951

ara

Harald đã viết:I just discovered that I recommended the wrong method, I misremembered what the proper solution was, sorry about that.

The proper way is to set skeletonRenderer.EditorSkipSkinSync = true, as described in this posting:
Dynamic Attachments Showing in Editor
This prevents the SkeletonRenderer Inspector from calling the respective code parts in UpdateIfSkinMismatch.
That works as expected! Thank you for getting back to me ,really appreciate it :D
Hình đại diện của thành viên
ara
  • Bài viết: 56

Harald

Glad to hear, thanks for letting us know! :nerd:
Hình đại diện của thành viên
Harald

Harri
  • Bài viết: 1951


Quay về Unity