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
Аватара пользователя
ara
  • Сообщения: 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
Аватара пользователя
Harald

Harri
  • Сообщения: 1976

ara

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
Thanks Harald!
I tried OnRebuild but it's not called.
Could you please take a look at my script :think:
У вас нет необходимых прав для просмотра вложений в этом сообщении.
Аватара пользователя
ara
  • Сообщения: 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.
Аватара пользователя
Harald

Harri
  • Сообщения: 1976

ara

Ok. Thanks! :D
Аватара пользователя
ara
  • Сообщения: 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.
Аватара пользователя
Harald

Harri
  • Сообщения: 1976

ara

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.
That works as expected! Thank you for getting back to me ,really appreciate it :D
Аватара пользователя
ara
  • Сообщения: 58

Harald

Glad to hear, thanks for letting us know! :nerd:
Аватара пользователя
Harald

Harri
  • Сообщения: 1976


Вернуться в Unity