mingjava Could you check if any of the conditions listed in the "重要须知" section of the Runtime 运行时重打包 section in the documentation apply to your case?: spine-unity 运行时文档 主要组件 #运行时重打包
合并皮肤之后,新的Spine形象的清晰度降低了
mingjava Unfortunately, there is no export setting to pack textures based on skins, but it is possible to pack texture atlas pages by folder. Therefore, if you have sorted images into folders by skin in advance, you can create texture packs for each skin. For more information, please refer to the following page in the Spine User Guide: Spine用户指南 纹理打包 #文件夹结构
mingjava I'm not sure if I fully understand your question due to the influence of machine translation, but regarding your last question about combining skins at runtime, yes, that is the recommended method. If you haven't seen Spine Examples/Other Examples/Mix and Match
yet, I recommend checking it out first. This scene is briefly introduced in the following video:
【[spine-unity] 通过示例场景开始使用spine-unity运行时】 【精准空降到 18:22】 https://www.bilibili.com/video/BV1DV4y1A7uf/?share_source=copy_web&t=1102
mingjava I see, I think I understand what you are trying to do. To begin with, dividing the same character into multiple skeletons is not a recommended method. If the reason for dividing into multiple skeletons is because it is troublesome to set up the skins, it may be better to replace the texture atlas page at runtime. This is the method described in the following general runtime guide:
Spine运行时指南 运行时皮肤 #创建附件
In other words, create each head part in a uniform size and pack them using the texture packer.
If the number and size of the input images match the texture packer settings, the texture packer will always pack the textures in the same layout. Therefore, by replacing the texture atlas page images loaded in Unity with the page images packed using this method, you can complete the change in the appearance of the skeleton.
However, this does require the effort of preparing parts images in a uniform size. So, ultimately, it depends on where you want to put your effort. In some cases, it may be easier to have many skins for a single skeleton, as there are fewer things to keep in mind when preparing parts images. In addition, using skins allows you to use skin bones and skin constraints, so if the complexity varies greatly depending on the skin (e.g., some skins require only five parts for the head, while others require 30 parts), it is easier to manage by using skins.
mingjava I apologize, but I may have lost track of what you are trying to do. However, I thought the following might be the information you are looking for, so I will add it as a supplement.
It is possible to reference a single texture atlas with multiple skeletons. If that's what you're looking for, the following threads may be helpful:
- https://esotericsoftware.com/forum/d/26758-%E5%A6%82%E4%BD%95%E8%AE%A9%E5%A4%9A%E4%B8%AAspine%E9%A1%B9%E7%9B%AE%E5%85%B1%E7%94%A8%E4%B8%80%E5%BC%A0%E5%9B%BE%E9%9B%86
- https://esotericsoftware.com/forum/d/25014-how-to-merge-atlas/4
Therefore, even if the skeleton is divided, each solution should work. Please let us know if it doesn't work.
A和B共用一个.skel.bytes文件
This cannot be achieved unless the same skeleton is used. It is not possible to merge skeletons that have been exported separately, so if this is one of your requirements, you should create characters A and B using the same skeleton.
If you ultimately want to merge into a single .skel.bytes
file, what is the actual reason for splitting the skeleton?
- Изменено
Misaki 目前我的A和B是使用的同一个骨骼,我是在运行时加载的三个导出的资源,类似与这样的代码,以便保证我获得的SkeletonGraphics都是使用的同样的骨骼,每个对象都包含三个皮肤attach,body,head。我现在的需求是,希望能够在运行时加载的A的皮肤attach和body,与B的皮肤head进行组合。这样是否可行?事实上,我已经实现了这样的功能,但是对于简单的比如待机的动作可以,但是复杂一些的攻击动作,涉及到层级变化的,动画效果就乱了。` // 创建资源
SpineAtlasAsset atlasAsset = SpineAtlasAsset.CreateRuntimeInstance(part.atlasText, part.textures, materialPropertySource, true);
SkeletonDataAsset skeletonDataAsset = SkeletonDataAsset.CreateRuntimeInstance(part.skeletonJson, atlasAsset, true);
// 创建SkeletonGraphic
SkeletonGraphic skeletonGraphic = SkeletonGraphic.NewSkeletonGraphicGameObject(skeletonDataAsset, this.gameObject.transform, skeletonGraphicMaterial);
skeletonGraphic.gameObject.name = $"SkeletonGraphic_{part.partName}";
skeletonGraphic.Initialize(false);`
mingjava ` // 创建资源
SpineAtlasAsset atlasAsset = SpineAtlasAsset.CreateRuntimeInstance(part.atlasText, part.textures, materialPropertySource, true);
SkeletonDataAsset skeletonDataAsset = SkeletonDataAsset.CreateRuntimeInstance(part.skeletonJson, atlasAsset, true);
// 创建SkeletonGraphic
SkeletonGraphic skeletonGraphic = SkeletonGraphic.NewSkeletonGraphicGameObject(skeletonDataAsset, this.gameObject.transform, skeletonGraphicMaterial);
skeletonGraphic.gameObject.name = $"SkeletonGraphic_{part.partName}";
skeletonGraphic.Initialize(false);`
mingjava I realized that maybe what you're really looking for is to use Multiple CanvasRenders
, Separator Slot Names
and Enable Separation
. Have you tried using those parameters?:
spine-unity 运行时文档 主要组件 SkeletonGraphic组件 #参数
(Although I have linked to the relevant section, this section is quite long, so it may be difficult to find the relevant item. Please scroll down to find the sections.)
You can use them to separate the rendering of the skeleton into any number of CanvasRenderers
in a single instance. If your needs do not necessarily require two instances, this method is much easier to handle in terms of animation synchronization and other aspects. (Rendering is separate, but animation is managed by a single AnimationState
.)
If you haven't tried it yet, it's worth giving it a try to see if it meets your needs.
The following thread may also be helpful:
https://esotericsoftware.com/forum/d/11375-separator-with-skeletongraphics/5