• RuntimesUnity
  • 텍스쳐가 계속 추가되어갈 때 유니티3d에서의 관리방법

안녕하세요 오늘도 열심히 스파인 툴을 만지고 있는 애니메이터입니다

나는 아주 많은 양의 텍스쳐가 들어가는 캐릭터를 작업하고 있습니다
이 캐릭터는 믹스 앤 매치 컴포넌트를 이용하여 여러 코스튬을 갈아입는 캐릭터이며 앞으로도 코스튬은 계속 늘어나게 됩니다. 그리고 우리 프로젝트는 자체툴을 만들어 스파인에서 export된 여러개의 아틀라스 텍스쳐 파일들을 유니티3d상에서 하나씩 재지정해 최적화하는데 사용하고 있습니다.

하지만 앞으로도 코스튬 텍스쳐가 추가된다면 스파인에서 export되는 텍스쳐의 숫자 이름이나 텍스쳐 형태가 변할것으로 예상되고, 이렇게 된다면 매번 유니티3d에 스파인 파일을 업로드할때

전체 스파인 파일을 삭제 -> 코스튬이 추가되어 재출력된 스파인 export파일 유니티에 업로드 -> 텍스쳐와 머테리얼들을 하나씩 다시 재지정 -> 코스튬 추가 -> 전체 스파인 파일을 삭제...(반복)

이런식으로 작업되고 있습니다. 앞으로 코스튬 텍스쳐가 계속해서 늘어날텐데 이때마다 모든파일을 삭제하고 텍스쳐 하나씩마다 다시 재지정을 해야하는 상황입니다.

질문 : 계속해서 코스튬 텍스쳐가 늘어나는경우 출력되는 아틀라스들의 이름을 고정하는 방법이 있을까요? 혹은 내가 원하는대로 이름을 지정하거나 순서가 변경되지 않고 추가되는 코스튬들이 뒷번호로 출력되게 하는 방법이 있을까요?(폴더 이름에 관련되어 아틀라스 번호가 할당되나요?) 그리고 유니티에 업로드시에 전체삭제하고 다시 업로드 하는것 말고 더 편한 방법이 있을까요?

    Related Discussions
    ...

    스파인에서 출력되는 아틀라스의 이름을 고정하거나 원하는 대로 지정하는 기능은 현재 스파인에서는 제공되지 않습니다. 그러나, 텍스처를 폴더 구조에 따라 별도의 아틀라스로 패킹하는 방법을 사용할 수 있습니다. 각 폴더에 pack.json 파일을 배치하여 폴더 구조를 유지하면서 텍스처를 패킹할 수 있습니다. 이는 각 생성된 아틀라스 페이지에 대해 다른 패킹 설정을 가질 수 있는 장점이 있습니다.

    Misaki a ajouté l'étiquette Unity le .

    bebete As Spinebot answered, you cannot specify the number of textures on each atlas page. Therefore, performing operations based on file names for skeletons whose textures are expected to be added later is not recommended.

    If there are a large number of skins, you may want to consider setting them at runtime rather than setting them all in Spine. This eliminates the need to re-export the skeleton each time a skin is added. For details, see the following documentation:
    https://esotericsoftware.com/spine-runtime-skins

    gpt와 구글링에서 pack.json을 사용하여 아틀라스 이름을 강제하는 방법이 있다고 이야기 하는것을 찾았습니다

    pack.json을 이용하면 아틀라스 파일 이름을 직접 지정할 수 있습니다.
    핵심은 pack.json 안의 "atlas" 항목입니다.
    {
    "atlas": "character_body", // → 아틀라스 파일 이름 강제 지정
    "format": "RGBA8888",
    "premultiplyAlpha": true,
    "scale": 1

    해당 이름을 직접 지정한 json을 텍스쳐들 폴더안에 같이 넣고 export를 하면 아틀라스 이미지의 이름이 강제적으로 지정된 아틀라스 패킹이 수행됩니까? 아니면 가짜정보인가요?

    해당 항목은 가짜정보로 밝혀졌습니다 스파인에서 export할때는 pack.json에서 할당한 아틀라스의 이름을 무시합니다 하지만 이런 정보를 발견했습니다

    방법 2: Spine 커맨드라인 툴 사용 (진짜 "atlas" 적용됨)
    bash
    Spine --export "프로젝트.spine" --output "export/" --pack
    → 이 방식은 pack.json의 "atlas" 이름이 정확히 반영됩니다.
    다만 에디터가 아닌 CLI 환경이라 자동화 파이프라인용입니다.

    자동화 파이프라인 환경에서는 pack.json에서 강제적으로 할당된 아틀라스 이름을 쓰게됩니까?

      bebete You can specify the atlas file name, but you cannot specify the page numbers or order. In other words, if you want to pack one page at a time, you can give each page a different name, but if you want to pack multiple pages in a single pack, you cannot specify which page will have the suffix _2 and which page will have the suffix _3.

      If you pack each page individually, you will get separate .atlas.txt files for each page.


      As you noticed, the format obtained from ChatGPT is invalid. The pack.json file does not have a setting for specifying the name of the atlas file.

      Packing via the command line interface (CLI) is essentially the same as packing individually by running the texture packer in the Spine editor. When launching the texture packer individually, you can also specify the atlas name:

      미사키가 말한대로 텍스쳐 패커에서 아틀라스 이름을 따로 지정하여 7개의 각각 다른 이름이 지정된 아틀라스들이 생성되었습니다. 해당 파일들을 유니티에 이식할 차례입니다. 미사키의 제안대로, 텍스쳐 패커로 출력된 아틀라스들은 그들을 묶어주는 스켈레톤 데이터가 없습니다. 그리고 텍스쳐 패커가 아닌 일반 내보내기로 생성된 스켈레톤과 아틀라스에 텍스쳐 패커로 출력된 아틀라스들을 한군데로 묶어보면 아틀라스.TXT에 기입된 좌표값이 달라서인지 이미지들이 깨지고 위치를 제대로 찾지 못하고 있습니다.

      텍스쳐 패커로는 스켈레톤 데이터를 생성할 수 없고, 일반 내보내기로 생성된 스켈레톤 데이터에는 텍스쳐 패커들을 넣었을 때 깨져버리는데 어떻게 해결해야 할까요?

        미사키는 역시 신적인 존재입니다 심지어 내가 스스로 질문했었던 예전글에 힌트가 있을줄은 상상도 못했습니다. 나의 어리석음에 오늘도 감탄하고 갑니다

        링크의 게시물대로, 나는 atlas를 열어 텍스트에 폴더네임/ 을 추가하였더니 텍스쳐의 깨짐현상은 완전히 사라졌습니다. 이것은 신세계였다. 이 방법으로 나는 모든것을 다시 시도해보고 있습니다 늘 스파인 포럼에서 희망을 얻고있습니다 감사합니다!

          bebete Oh, I didn't realize that the thread I linked to was the one you created. Anyway, I'm glad your issue was resolved! If you have any questions or get stuck in the future, please feel free to ask us. 🙂

          한 가지 더 질문이 있습니다!

          Spine에서 images 폴더 내에 여러 하위 폴더와 각각의 텍스처가 있을 때, 내보내기 옵션 → 이미지 폴더로 출력을 사용하면 생성되는 아틀라스 이미지 파일이 atlas.png, atlas1.png, atlas2.png, atlas3.png … 이런 식으로 자동으로 이름이 지정됩니다.

          이때 이 아틀라스 파일들의 생성 순서는 images안에 존재하는 폴더들의 이름 순으로 고정되어 출력되는 것인지 궁금합니다.

          만약 이 순서가 항상 폴더 이름 순으로 정해지는 것이 확정이라면, 굳이 복잡한 최적화 작업 없이도, 저는 출력되는 이미지 이름 규칙을 기반으로 엔진에서 자동으로 이름을 매칭 및 할당해주는 툴을 만들어 대응할 수 있을 것 같습니다!

            일치하지 않는다면 문제점이 다시 처음으로 돌아가버립니다. 스파인 툴이 더 넒게 쓰이고 더 많은 부분의 영역을 담당하게 됨에 따라 더 무거운 프로젝트, 더 많은 텍스쳐, 더 많은 최적화가 계속해서 이루어지려 하고 있습니다. 나는 약 한달이 넘는 시간동인 이 문제에 대해 추적해왔고 제가 쓴 포럼들의 질문 히스토리를 보면 아시겠지만 이 문제 해결에 다대한 관심을 가지고 있습니다. 추적의 결과

            1. 텍스쳐 패커를 사용하여 아틀라스 이미지를 특정해 유니티에서 새로 조합하기 -> 비효율적이며 스파인 파일이 수정될때마다 계속해서 atlas.txt를 수동으로 수정해줘야함

            2. 내보내기 -> 이미지 폴더로 출력하면 아틀라스 이미지들이 정확한 규칙에 따라 만들어지는 보장이 없이 생성되기 때문에 유니티에서 매번 스파인 파일을 수정할때마다 기존 이미지들을 특정할 수가 없어 수동으로 다시 재지정해줘야 함

            3. 텍스쳐 패커를 전부 사용한 후 스켈레톤 데이터에 atlas를 추가하여 텍스쳐 패커에서 나온 atlas 파일들을 넣어서 조합 -> 하나의 스켈레톤 데이터에서 계속해서 모든 atlas를 미리 로딩해야하기 때문에 최적화에서 불리함

            4. 자체제작 툴을 만들어 유니티에서 업로드된 스파인의 아틀라스 텍스쳐들의 이름과 atlas.txt를 자동으로 변환 -> 위에서 서술했듯이 스킨 폴더가 계속해서 추가되었을 때 자체제작 툴이 기존 아틀라스 이미지를 기억하지 못하기 때문에 매번마다 수동으로 재지정 해줘야하고 이는 효율적이지 못하며 라이브 서비스 시에 치명적인 실수로 동작할 수도 있음

            5. Spine Addressables Extensions을 사용하여 최적화에 큰 도움을 줄 수 있음 하지만 지금 내가 원하는 근본적인 해결책은 아님.

            결국 내가 원하는것은 출력된 아틀라스 이미지의 이름이 완전히 특정될 수 있는 상황이며 이는 텍스쳐 패커 기능으로 해결되는 듯 했으나 결국 유니티에서 조립할때는 다시 일일히 수동으로 할당해줘야 한다는 결말이 나옵니다.

            스파인에서 이미지폴더로 출력시에 images폴더 안에 있는 폴더의 이름 순서대로 아틀라스 이미지가 묶여서 출력되는것이 확실할 때 이 모든 문제가 매우 간단하게 해결될 것 같습니다.

            불행히도 폴더 이름 순서로 제작되는것이 확실하지 않고, 오랜시간동안 이 문제에 대해 아직 완벽한 답을 찾지 못하였습니다. 계속해서 스터디를 이어나가며 포럼에 자주 들르겠습니다. 제가 서술한 방법 이외에 다른 방법이 있다면 누구든 부디 의견을 내어 도와주시길 바랍니다.

            ps. 반복적으로 테스트했을때 폴더 이름 순서대로 아틀라스 이미지가 패킹되는것을 확인하였는데 이것이 매번마다 100% 확실치 않다는 것이죠?

              bebete 텍스쳐 패커를 사용하여 아틀라스 이미지를 특정해 유니티에서 새로 조합하기 -> 비효율적이며 스파인 파일이 수정될때마다 계속해서 atlas.txt를 수동으로 수정해줘야함
              Using TexturePacker to define the atlas image and reassemble it in Unity
              → Inefficient. Every time the Spine file is modified, I have to manually update the atlas.txt file.

              I'm not sure I understand your question and use case correctly, but please note that especially if your project is large and complex, it's all the more important to have automated scripts export all your skeleton assets at once. Then copy them over to the respective Unity project directories. If you need any additional steps inside Unity to assign any asset references, this should also be automated via Unity Editor scripting. This should never be inefficient or require tiresome and error-prone manual export steps.

              내보내기 -> 이미지 폴더로 출력하면 아틀라스 이미지들이 정확한 규칙에 따라 만들어지는 보장이 없이 생성되기 때문에 유니티에서 매번 스파인 파일을 수정할때마다 기존 이미지들을 특정할 수가 없어 수동으로 다시 재지정해줘야 함
              Exporting to an image folder
              → Since there’s no guarantee the atlas images will be generated following a consistent rule, every time I modify the Spine file, Unity can’t identify the existing images, so I have to manually reassign everything.

              They are generated with a consistent rule, but the page count and assignment of regions to individual pages of course may vary, unless you create enough subdirectories to ensure there is only one page per subdirectory. The main question is, why is that a problem?

              Regarding the part "Unity can’t identify the existing images, so I have to manually reassign everything.": This should never be the case and sounds more like improper workflow setup. All atlas page textures are automatically assigned at materials and materials at AtlasAssets, according to the atlas.txt file. What exactly do you manually assign here?

              텍스쳐 패커를 전부 사용한 후 스켈레톤 데이터에 atlas를 추가하여 텍스쳐 패커에서 나온 atlas 파일들을 넣어서 조합 -> 하나의 스켈레톤 데이터에서 계속해서 모든 atlas를 미리 로딩해야하기 때문에 최적화에서 불리함
              Using TexturePacker entirely and adding the atlas to the skeleton data
              → This requires preloading all atlases for a single skeleton data file, which is disadvantageous in terms of optimization.

              I'm not sure I understand this section. If you want to optimize download size and load times, you primarily have to optimize texture loading. The atlas asset and materials should be negligible in comparison. Delayed on-demand texture loading is provided via the spine-unity Addressables extension UPM package that you mentioned as well. Is there a reason you can't or don't want to use it?

              자체제작 툴을 만들어 유니티에서 업로드된 스파인의 아틀라스 텍스쳐들의 이름과 atlas.txt를 자동으로 변환 -> 위에서 서술했듯이 스킨 폴더가 계속해서 추가되었을 때 자체제작 툴이 기존 아틀라스 이미지를 기억하지 못하기 때문에 매번마다 수동으로 재지정 해줘야하고 이는 효율적이지 못하며 라이브 서비스 시에 치명적인 실수로 동작할 수도 있음
              Developing a custom tool to automatically convert the atlas texture names and atlas.txt in Unity
              → As mentioned above, if skin folders are continuously added, the tool can’t remember the previous atlas images. This means I have to manually reassign them every time, which is inefficient and can cause critical errors during live service.

              I'm not sure I understand the above correctly, but your automation scripts should automatically work in all cases, when any output atlas subfolders to be packed are added, your scripts shall automatically cover that perfectly. If your scripts don't automatically convert and prepare all directories, you should modify your export scripts accordingly. Regarding a live service, it's even more crucial to prepare and upload everything automatically, there should be no manual steps involved, which will otherwise lead to potential errors.

              Spine Addressables Extensions을 사용하여 최적화에 큰 도움을 줄 수 있음 하지만 지금 내가 원하는 근본적인 해결책은 아님.
              Using Spine Addressables Extensions
              → This can help significantly with optimization, but it’s not the fundamental solution I’m looking for.

              The question is what fundamental problem are you trying to solve? And why does on-demand loading of larger assets not help you with that?

              결국 내가 원하는것은 출력된 아틀라스 이미지의 이름이 완전히 특정될 수 있는 상황이며 이는 텍스쳐 패커 기능으로 해결되는 듯 했으나 결국 유니티에서 조립할때는 다시 일일히 수동으로 할당해줘야 한다는 결말이 나옵니다.
              What I ultimately want is for the output atlas image names to be completely predictable. It seemed like this could be solved using the TexturePacker feature, but in the end, when assembling things in Unity, it still requires manual assignment every time.

              There should never be any manual assignment of these assets necessary. If it is required, something is wrong with your setup. Even if you have several separate .atlas.txt files with unknown and varying count, your export scripts and Unity Editor import scripts should be written in a way that they add all AtlasAssets to the SkeletonDataAsset list.

              스파인에서 이미지폴더로 출력시에 images폴더 안에 있는 폴더의 이름 순서대로 아틀라스 이미지가 묶여서 출력되는것이 확실할 때 이 모든 문제가 매우 간단하게 해결될 것 같습니다.
              If it were guaranteed that when exporting to an image folder, the atlas images would be grouped and exported in the order of the folder names inside the images folder, this entire issue could be resolved very simply.

              What do you want to be grouped here, what do you want to rely on here? Why is it important for you and why would the setup not work if it were different each time?

              If it's all for automatically loading an AtlasAsset in your game when a skin is assigned, with all associated materials and atlas page textures, you should automatically update your Unity project and automatically update and upload all affected addressable packages. There should be no manual steps involved where you could forget anything or cause subsequent errors.

              In generalt however I would recommend just optimizing texture downloading, e.g. via the spine-unity Addressables UPM package, and loading all "empty" AtlasAssets up front, which should not pose any performance issues as such.

              반갑습니다 해럴드!
              지난번에 주신 상세한 답변 감사드립니다.
              제가 겪고 있는 문제와 답변 내용 사이에 약간의 오해가 있는 것 같아, 상황을 명확히 설명드리고자 합니다

              여러 코스튬을 합쳐서 표현하는 방법을 스파인의 MixAndMatch 와 Repack 구조로 캐릭터 코스튬을 관리하고 있습니다.

              1. SkeletonGraphic 을 사용합니다.

              2. 각 코스튬 파츠별로 독립된 메터리얼과 텍스쳐를 가지고 있습니다.

              3. 스켈레톤 데이터에 Atals 데이터는 코스튬의 갯수와 상관없이 하나의 .atlas 파일로 관리하고 있으며 복장이 추가될때마다 해당 atlas 파일에 정보가 추가됩니다.

              4. 복장은 입는 부위가 3가지인데 ( hair, cloth, accessory ) 선택된 복장의 ID 를 기억하고 있다가 하나로 합쳐서( MixAndMatch, Repack ) 표현하고 있습니다.

              5. 그래서 최적화를 위해 위의 3가지 복장을 조합할 때 텍스쳐를 따로 로딩해서 적용을 할려고 시도하고 있습니다. ( Addressable 도입 )

              6. 예를 들어 여름 복장의 헤어 코스튬의 텍스쳐가 LB_01.png 로 무작위로 스파인 데이터를 유니티에 옮길 때 생성 되었다면 , LB_01.png 라는 파일 이름을
                외부 DB 에 연결해서 ID 를 부여해서 이 여름 복장 헤어 코스튬 복장을 착용할 때는 LB_01.png 를 호출하게끔 할려고 합니다.

              7. 문제는 스파인에 코스튬을 추가할 때에 스파인 데이터를 작업한 걸 유니티로 옮기면 기존에 여름 복장의 헤어 코스튬의 텍스쳐가 기존의 LB_01.png 라는 보장이 없다는 겁니다.

                이 부분에 대해서 어떻게 해결 할 수 있는지가 질문의 포인트입니다!

              @bebete If you have just a single atlas asset and just want to download atlas texture pages on-demand, you should likely be using the Spine Addressables extension UPM package, which does exactly that for you. If you need some database indirection, you could write your own on-demand loading module based on the spine-unity Addressables UPM package, with modifications where necessary.

              문제는 스파인에 코스튬을 추가할 때에 스파인 데이터를 작업한 걸 유니티로 옮기면 기존에 여름 복장의 헤어 코스튬의 텍스쳐가 기존의 LB_01.png 라는 보장이 없다는 겁니다.
              The problem is:
              When new costumes are added to Spine and the data is imported into Unity, there’s no guarantee that the texture for the summer hair costume will still be named LB_01.png.

              You could use subfolders with pack.json files and automatically detect when more than a single atlas page is generated (and then issue an error to be fixed by a developer) to ensure it always ends up with the same predictable name. Nevertheless, it's not the best solution and more of a misuse and turning the atlas packing concept on its head.

              The clean solution would be to automatically use export scripts and Unity Editor import scripts (and data-base setup and update scripts) which update all your mappings in all places. See the on-demand-loading UPM packages, which manage just that: resolving the required textures when the attachments are needed. You should (1) never have to rely on certain attachments being located in certain atlas pages and (2) analyse and setup attachment-to-atlas-page-texture mappings for downloading automatically via Unity Editor scripts or other automation scripts. That's what I was suggesting in my above reply. If you manually setup any mapping like "this attachment or skin requires that atlas page", you're using an error-prone workflow. Then instead you should be using automated systems which create the mapping correctly for you every time and make sure all assets are in the right places.

              답변 감사합니다!
              내용이 길어졌으므로 요약해보겠습니다

              목표 구조
              Spine의 아틀라스 export 결과가 바뀌더라도,
              Unity 쪽에서 어태치먼트 이름이나 스킨 정보를 기반으로 .atlas.txt 파일을 자동 분석하여
              어떤 텍스처(asset addressable)들을 불러와야 할지를 매핑하는 시스템을 구축하는 것.

              해럴드의 요약
              텍스처 이름(LB_01.png 등)에 의존하는 건 비추.
              이유: Spine은 export 시 텍스처 이름을 보장하지 않기 때문에, 특정 이름을 외부 DB에서 참조하려는 방식은 깨지기 쉬운 구조라는 것.

              대신 자동화된 매핑 시스템을 사용하라.
              Spine Addressables UPM 패키지로 온디맨드 텍스처 로딩.
              Unity Editor 스크립트로 .atlas.txt 분석 → 어태치먼트와 텍스처 매핑 자동화.
              텍스처 파일 이름이나 순서에 의존하지 않고, 어태치먼트 이름 기준으로 매핑 구조를 구성하라는 조언.

              여기까지 정리한 내용이 맞는지 확인 부탁드립니다.

              또한 이를 위해 궁금한 점이 있습니다:

              1. Spine Addressables UPM 패키지를 기반으로, .atlas.txt에 기재되는 스킨 이름 기준으로 필요한 아틀라스 텍스처를 동적으로 로딩하고 연결하는 샘플이나 워크플로 문서가 있을까요?

              결국 제가 원하는 건 파일 이름(LB_01.png 등)에 의존하지 않고,
              Spine 데이터만으로 Unity에서 텍스처 자동 로딩을 안정적으로 구현하여 작성된 데이터 시트에 매칭하는 구조입니다.

              @bebete Glad it's helpful. Your summary was almost correct:

              대신 자동화된 매핑 시스템을 사용하라.
              Instead, use an automated mapping system

              Yes, this is correct.

              Spine Addressables UPM 패키지로 온디맨드 텍스처 로딩.
              Use the Spine Addressables UPM package for on-demand texture loading.

              This is recommended, yes. If there is nothing preventing you from using it, it will do everything for you and you don't need any custom solution. So you should not need to analyze anything via scripts. The analysis would only be necessary if you can't use the Spine Addressables UPM package as-is.

              Unity Editor 스크립트로 .atlas.txt 분석 → 어태치먼트와 텍스처 매핑 자동화.
              Use a Unity Editor script to analyze .atlas.txt → automate attachment-to-texture mapping.

              Sorry if this was not clear. I did not mean to directly analyze the .atlas.txt file, instead it should be easier to analyze the result after automatic import. So you can analyze the Atlas object returned from AtlasAssetBase.GetAtlas(). You can access all Atlas objects of a SkeletonDataAsset (usually just one) e.g. via SkeletonDataAsset.atlasAssets. The Atlas object then provides Atlas.Regions.

              텍스처 파일 이름이나 순서에 의존하지 않고, 어태치먼트 이름 기준으로 매핑 구조를 구성하라는 조언.
              The advice is to build the mapping system based on attachment names, without relying on texture file names or ordering.

              If you need a mapping, and for some reason can't use just the Spine Addressables UPM package without additional indirection layers, yes, this is correct.

              10 jours plus tard

              모든 스터디를 마치고 돌아왔습니다! 그리고 나는 내가 원하는 기능을 찾아내어 적용할 수 있게 되었습니다.
              핵심은 말씀드렸듯 텍스쳐의 최적화와 자동 맵핑기능이었고 이것은 해럴드의 설명대로 입니다
              한가지 착오가 있던 것은 그 기능이 유니티 엔진에서 손쉽게 구현된다는 것을 몰랐던 것입니다
              아틀라스 파일에서 아이콘을 우클릭 하면 나오는 애드 어드레서블 로더라는 항목을 나는 이제서야 발견하였고 이것으로 내가 원하던 목표를 이룰 수 있었습니다!
              해럴드와 미사키의 무한한 헌신과 인내심에 늘 감사드립니다!
              행복한 하루!

              We're very glad it helped, thanks for your kind words! Have a great day, too!