• RuntimesUnity
  • 使用repackedSkin组合皮肤后4.2物理效果不显示

您好,我在unity中repack了两个不同spine gameobject的skin,组合成一个新skin,但是组合后spine4.2的Physics Contrain不起作用了
这是我的代码:
if (Input.GetKeyDown(KeyCode.J))
{
id0++;
if (id0 > 2)
id0 = 0;
//Head,Chest,Crotch分别是头部铠甲,胸甲和腿甲
pModel是一个skeletonAnimation的List,存有所有装备的玩家
Spine.Skin skinHead =pModels[id0].Skeleton.Data.FindSkin("
Head");
Spine.Skin skinChest = pModels[id1].Skeleton.Data.FindSkin("Chest");
Spine.Skin skinCrotch = pModels[id2].Skeleton.Data.FindSkin("
Crotch");
Spine.Skin skinMix = new Spine.Skin("Mix");
skinMix.AddSkin(skinChest);
skinMix.AddSkin(skinCrotch);
skinMix.AddSkin(skinHead);
skeletonAnimation.Skeleton.SetSkin(skinMix);
skeletonAnimation.skeleton.UpdateCache();
skeletonAnimation.skeleton.SetSlotsToSetupPose();

		Spine.Skin repackedSkin = skinMix.GetRepackedSkin("RepackedSkin", skeletonAnimation.skeletonDataAsset.atlasAssets[0].PrimaryMaterial,
			out var _,
			out var _);
		skinMix.Clear();
		skeletonAnimation.Skeleton.SetSkin(repackedSkin);
		skeletonAnimation.skeleton.UpdateCache();
		skeletonAnimation.skeleton.SetSlotsToSetupPose();
	}
  • ring님이 이에 답장했습니다.
    Related Discussions
    ...

    在使用 GetRepackedSkin 方法组合皮肤后,Spine 4.2 的物理效果不显示的问题可能与几个因素有关。首先,确保所有要重新打包的纹理都启用了 Read/Write 属性,因为这在重新打包过程中是必要的。此外,检查纹理的压缩设置,确保它们没有被压缩,因为这可能会影响重新打包的结果。最后,确保在设置新皮肤后,调用 skeletonAnimation.skeleton.UpdateCache()skeletonAnimation.skeleton.SetSlotsToSetupPose() 来更新骨架的缓存和设置插槽到初始姿势。

    如果这些步骤都没有解决问题,可能需要检查是否有其他因素影响了物理效果的显示,例如在重新打包过程中丢失了某些物理约束或骨骼设置。

    ring 我的运行库为spine-unity Runtime Version 4.2.85

    • ring님이 이에 답장했습니다.

      ring 我试着导出了两个完全同样的spineGameobject到unity中,但是即便完全相同,切换前起作用的物理约束在切换后失去了作用

      @ring Sorry to hear you're having troubles. Are you using Skin Bones in your project, and perhaps deactivating some of the bones that your Physics Constraints are based on?

      Could you please have a try wheter updating the spine-unity runtime to the latest version (4.2.100) resolves the issue? If not, could you please create a minimal Unity project which still shows this issue? You can send it to us as a zip file to contact@esotericsoftware.com, briefly mentioning this forum thread URL so that we know the context.

      • ring님이 이에 답장했습니다.

        Harald 非常感谢你的回复,我已经把复现问题的小型unity工程文件通过邮件发给你们了

        • Misaki님이 이에 답장했습니다.

          ring Thank you for sending us your Unity project file! Unfortunately, the Unity project you sent us contained many unnecessary files. If you would like to send us a project that reproduces the issue in the future, please send us a compressed file containing only the following folders:

          • Assets
          • Packages
          • ProjectSettings

          Anyway, I checked your Unity project, and it was quite different from the typical setup for using skins, so I would first like to confirm why you chose this approach.
          Your skeleton's skin was used almost exclusively to manage bones and constraints, and was not used to change the appearance. In your approach, you prepared two skeletons with different appearances and changed the appearance by changing the prefab itself. Could you explain why this approach is necessary? The general approach is to have a skeleton with skins that make up multiple appearances, as shown in the mix-and-match example.

          • ring님이 이에 답장했습니다.

            Misaki 这是因为我在做一个Dark Souls Like Game,有大量的动画和换装需求,目前还只有36套装备,可是我导出文件时都需要大量时间,这对我现在的开发工作来说很浪费时间

              ring 补充一下,我曾经把36个装备作为skin做进了一个工程文件里,也就是您所提到的方案

              ring I see, thank you for the explanation. In that case, we recommend replacing only the textures, as described in the general runtime guide:
              Spine运行时指南 #创建附件

              Creating multiple skeletons for the same character requires extra effort to ensure that all skeletons are in the same state when changes are made to the skeleton rig or animation.

              In addition, having player characters with a large number of different equipment combinations is a very common scenario in game development using Spine. The management of skins and textures in such cases has been discussed extensively in the past, so I recommend that you review the previous threads in this forum if you have not already done so.

              (I understand that I did not answer your question regarding physics constraints, but your approach was to replace the prefab skeleton itself rather than changing the skin, so I did not answer that question because I believe this issue will likely be resolved if you manage the same character with a single skeleton.)

              • ring님이 이에 답장했습니다.

                Misaki 很抱歉我现在才回复您,我今天才刚刚从工作中脱身。
                demo scene里的mix and match让我明白了spine换装的标准做法,我的问题已经解决了,非常感谢你们的帮助

                • Misaki님이 이에 답장했습니다.
                • Misaki 님이 이 게시물을 좋아합니다..

                  ring I'm glad to hear that the problem has been resolved! Thank you for getting back to us!