• Editor
  • Copy / Paste Bone transforms

Hi,

Would it be possible to synthesize the data structure to modify a bone transform with data copied from outside Spine?

We want to modify a bone position. Using pixi runtimes can we retrieve the adjusted bone transform and paste it into Spine directly?

Thanks!
Best regards,

  • Erika ha risposto a questo messaggio
    Related Discussions
    ...

    To modify a bone transform in Spine using data copied from outside Spine, you would need to understand the data structure used by Spine for bone transforms. Spine allows you to copy and paste bone transforms within the editor, which includes rotation, translation, scale, and shear. However, directly pasting data from an external source into Spine is not supported through the standard interface.

    If you are using the Pixi runtime, you can manipulate bone transforms programmatically by accessing the bone's properties and adjusting them as needed. You can retrieve the current transform values from the Pixi runtime, modify them, and then apply these changes back to the Spine skeleton in your application. However, these changes would not be reflected in the Spine editor unless you manually update the skeleton data in Spine.

    fantasma_oskar What's the aim of this procedure precisely? Perhaps there could also be a simpler or different way to achieve it?

    Hi,
    the aim is to bring a bone transform into Spine from an outside source. 🙂 Adjusting the final placement for e.g UI components is easier to do in our application when all aspects can be viewed at the same time.

    Best regards,

    • Davide ha risposto a questo messaggio

      fantasma_oskar

      Do you want to modify it at runtime, or do you want to modify the values of the exported asset so that it is loaded with your modified values? In the latter case, it's easier to manipulate JSON.

      Have you seen the JSON format documentation? Have a look at the bone structure here.

      Hi,

      Thanks for your suggestion! We want to modify transforms in the spine project itself so that the next person who works with it has the same values as well. Modifying the JSON is not the correct way to achieve this, that would be more like painting over exported texture atlases instead of modifying the source files.

      Another way to do it is of course to modify the JSON and import that into the project, but this doesn't seem like good UX since there are more steps involved and more knowledge required to not mess everything up. I think good UX would be to allow it being copy/pasted directly into the application.

      Best regards,
      Oskar

      • Davide ha risposto a questo messaggio

        fantasma_oskar

        Oh, sorry, I misinterpreted your question. I don't know why I thought I saw the "runtime" label on the thread.
        However, it's still not clear to me what your goal is. As far as I understand, you want to copy bone transform values retrieved from Pixi into the Spine project. Is that correct?

        You can obtain the transform values from Pixi, but you cannot paste them into a bone in the editor as if you were pressing CTRL+C on one bone and CTRL+V on another. What you can do is manually copy the numeric values for translation, rotation, and scale into the editor.

        Is this your goal?

          Davide

          "You can obtain the transform values from Pixi, but you cannot paste them into a bone in the editor as if you were pressing CTRL+C on one bone and CTRL+V on another. What you can do is manually copy the numeric values for translation, rotation, and scale into the editor."

          We want to be able to paste them into a bone in the editor using CTRL-V. Manually copying the numeric values is both tedious and requires many more steps compared to a single CTRL-V.

          Is there a specific data format / structure that the Spine editor interprets as proper Bone transforms that can be "faked" by populating the clipboard correctly?
          E.g as JSON? {"scale":{"x":0.9, "y":1.1}, "position":{"x":150,"y":-150} ...etc}

          Since copying a single numeric value and pasting it into the editor works, and copying bone transform in editor works, could something like that be done?

          Best regards,
          Oskar

          • Davide ha risposto a questo messaggio

            fantasma_oskar

            Thanks for the thorough explanation.
            Unfortunately, as anticipated, you can't do it. When you copy (CTRL-C) a bone transform within the editor, the transform values are not stored in the OS clipboard but in the editor's internal state. When you paste (CTRL-V) into the editor with a bone selected, the editor searches within its internal clipboard, not the OS one.

            From a theoretical point of view, it's an interesting option. However, users should copy values that have a specific syntax. It might be quite difficult to use.

            Yeah, I figured as much since the clipboard data was not possible to paste outside Spine. 😅
            Would it be possible to support this and expose the data structure for those that are interested in using it? I.e Spine checks the OS clipboard data: verifies whether its applicable / valid to apply at current state and if not: falls back to the Spine clipboard? 🙂

            It would enable applying changes between users and packages/runtimes in a very straightforward manner. E.g sending copied transforms to a collegue for pasting.

            Not saying it should be implemented into runtimes right away, just exposing the data structure. 🙂

            Best regards,