• International中文
  • 如何更改导出的二进制数据的命名

我在Spine工程中制作了多个角色通过同一骨架不同皮肤的形式,我想将不同角色的皮肤和其所对应的动画按角色分别导出成二进制文件以供Unity使用,但是每次导出的时候命名都是以骨架的名称进行命名,不能很好的进行区分,请问我需要做什么才能更改导出的二进制文件的命名

Related Discussions
...

You don't need a skeleton data file for each character. A skeleton is always exported as a single file. At runtime you load that file once, then create any number of skeleton instances. You configure each skeleton instance to have the skin(s) corresponding to which character it is.

  • ECG_Kinsey ответили на это сообщение.

    Nate 如果这么做,当我一个骨架下创建几十个角色几百个皮肤的时候,导出为同一份骨架数据,所有的皮肤所依赖的贴图都会被打包成同一个图集,这将导致这个图集文件非常大,可能超过了unity导入的贴图尺寸上限。

    Texture atlases are separate from the skeleton data. You can choose to load only the texture atlases you need.

    Note you can pack your atlases separately from exporting the skeleton data:
    https://zh.esotericsoftware.com/spine-texture-packer#%E5%8D%95%E7%8B%AC%E8%BF%90%E8%A1%8C%E7%BA%B9%E7%90%86%E6%89%93%E5%8C%85%E5%99%A8%E3%80%82

    Alternatively, instead of packing an atlas beforehand, you can distribute individual images in your app and pack them into an atlas depending on what skins are visible. You can choose skins based on what characters are in a level, what weapons they have, etc. This is more complex, but allows you to have many thousands of attachments. When you have such a large number, you probably want to attach only template images in the Spine editor, then you create attachments dynamically at runtime to replace the template attachments. See:
    https://zh.esotericsoftware.com/spine-runtime-skins#%E5%88%9B%E5%BB%BA%E9%99%84%E4%BB%B6
    English version:
    https://en.esotericsoftware.com/spine-runtime-skins#Creating-attachments

    We have an example of doing this here (English, sorry):
    http://esotericsoftware.com/spine-unity-mix-and-match

      Nate 您的建议很有用,可以有效的解决同一个角色的相同部位拥有不同附件导致的贴图数量巨大的问题。

      我们的项目中,考虑到动画的复用,不同的角色制作也是通过皮肤的形式,他们都拥有相同的基础人型骨骼,但是也有拥有各自的差异化骨骼,就算我们只保留每个角色的模板贴图,这也将是一个不小的贴图规模,考虑到图集大小以及不同角色单独渲染批次,我们希望使不同角色的模板贴图分开打包成单独的图集纹理。

      我们将每个角色的对应模板贴图放置于单独的子目录中,尝试使用打包设置中的图片文件夹结构进行打包,这达到了不同角色不同图集的效果,但是每个打包产出的图集纹理的命名均是以骨架名字组合索引的形式进行命名,这将不太容易区分不同图集纹理属于哪个角色。请问我应该如何做才能让打包产出的图集纹理以子目录的名字进行命名?

      When you use template images in Spine, you don't need to pack them into an atlas. At runtime, you don't use the template images at all, they are only for visualization in the Spine editor. You load only the skeleton data without images, then you modify the template attachments to have the actual images you want.

      I understand you moved your images to a subfolder for each character. It's not clear how you packed these into an atlas. If you packed the parent folder, the result will be one atlas with the images for each character on a separate atlas page (PNG). If you don't want to load all the PNGs at once, at runtime you'll need to load the atlas data, then selectively load the PNGs. The PNGs are not currently named after the subfolder -- we will look at doing that. One thing you can do is to find a region in the atlas (using findRegion) that you know is for a particular character. From that region you can get the atlas page and the page's name matches the PNG file.

      To make it easier at runtime, you can just pack an atlas for each character. I suggest to write scripts to do this. Then you just load the atlas corresponding to the character.

      • ECG_Kinsey ответили на это сообщение.

        Nate 是的,我们目前的打包产物为一个图集描述文件(TXT)对应多个角色图集贴图(PNG),正如您建议的,我们计划在运行中加载对应角色的图集贴图而非一次性加载全部贴图。目前看来这个做法将能很好的满足我们的需求。

        除此之外,在使用打包设置中的图片文件夹结构进行打包的前提下,是否能同时剔除不被附件所引用的图片,目前这好像是两个单独的功能,不能同时使用,我只有选择以“附件”形式进行打包,才能过滤掉不被附件所引用的图片。

        I'm glad that will work for you! Though I still contend that it is easiest to write a shell script that packs an atlas for each character. Using shell scripts is good because you don't need to rely on animators or developers to do the packing correctly.

        When exporting skeleton data and packing a texture atlas at the same time, the "Pack [Attachments]" option will only pack attachments in use by the skeleton. Otherwise, if you pack using "Pack [Image folder]" or you run the texture packer separately from skeleton data export, it packs all the image files it finds. In that case you'll want to keep your images folder clean, so it only has image files that are being used.

        You can see in the editor which image files are not used. Used files are shown green, unused files are shown orange:

        Изображение удалено из-за отсутствия поддержки HTTPS. | Показать

        You can "clean" your images folder by packing an atlas during skeleton data export using "Pack [Attachments]", so it contains only used images, then unpack that atlas to get individual image files again, without any unused image files.