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
User avatar
ara
  • Posts: 58

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
User avatar
Harald

Harri
  • Posts: 2076

ara

Harald wrote: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:
You do not have the required permissions to view the files attached to this post.
User avatar
ara
  • Posts: 58

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.
User avatar
Harald

Harri
  • Posts: 2076

ara

Ok. Thanks! :D
User avatar
ara
  • Posts: 58

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.
User avatar
Harald

Harri
  • Posts: 2076

ara

Harald wrote: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
User avatar
ara
  • Posts: 58

Harald

Glad to hear, thanks for letting us know! :nerd:
User avatar
Harald

Harri
  • Posts: 2076


Return to Unity