【问题标题】:Texture Packer Command line multiple imagesTexture Packer 命令行多个图像
【发布时间】:2015-08-26 11:00:28
【问题描述】:

我在命令行中使用 TexturePacker,但无法将多个精灵打包到一张表中。它允许我做 1 个精灵,所以命令很好。

这是我正在使用的命令。

"TexturePacker --format sparrow --texture-format atf --opt DXT5 --max-width 2048 --max-height 2048 --size-constraints POT --pack-mode Best --enable-rotation --trim-mode Trim --algorithm MaxRects --multipack --border-padding 5 --shape-padding 5 --reduce-border-artifacts --scale " + sheetInfo.scale + " --data " + imageOutputDirectory + "\" + lanfPrefix + "\" + sheetInfo .name + “.xml” + “--sheet” + imageOutputDirectory + “\” + lanfPrefix + “\” + sheetInfo.name + ".atf image1.png image2.png";

任何想法为什么这不起作用?根据文档,它应该可以工作。

【问题讨论】:

    标签: cmd texturepacker


    【解决方案1】:

    我无法找到任何真正的方法来解决这个问题,甚至联系了纹理打包器的开发人员但没有得到任何回应。相反,我能够通过将所有需要的文件复制到一个临时目录,然后将该目录添加到 texturepacker 调用的末尾而不是单个图像来实现预期的结果。

    【讨论】:

      【解决方案2】:

      由于 TexturePacker 文档不佳,我花了很多时间反复试验才弄清楚这一点!

      要将多个图像添加到单个精灵表,这里有一个示例命令,它将创建一个名为 out.png(默认)的图集,其中包含图像 img_1 到 img_4...

      TexturePacker --format unity-texture2d img_1.png img_2.png img_3.png img_4.png
      

      关键是仅用空格分隔的图像文件名列表。我正在使用 Python 工作,所以这里是我用来创建与上面示例行将提供给您的相同图集的脚本。使用带通配符的 glob 允许我从包含许多图像的文件夹中选择图像,并且无需为了 TexturePacker 而将我想要的文件隔离到一个文件夹中。

      import subprocess, glob
      TP = r"C:\Program Files\CodeAndWeb\TexturePacker\bin\TexturePacker.exe"
      baseFrame = "img"
      def FillAtlas(baseFrame):
          globString = baseFrame + "_*.png"
          frameList = glob.glob(globString)
          imgList = []
          for frame in frameList:
              imgList.append(frame)
          TPargs = [TP, "--format", "unity-texture2d"] + imgList
          subprocess.call(TPargs)
      
      FillAtlas(baseFrame)
      

      【讨论】:

      • 谢谢,我仍在使用我的旧方法,但当我有空闲时间重写我的脚本并重新排序我的资产时,可能会改用这种方法。
      猜你喜欢
      • 2016-04-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-04-13
      • 2012-03-07
      • 1970-01-01
      • 2015-09-30
      相关资源
      最近更新 更多