• RuntimesUnity
  • Managing multiple Skeleton Animation from a single script

Hello everyone!

I've been struggling with a minor problem, but I have the feeling that I'm not doing this the optimus way, so I'm going to explain what i want to achieve in case anyone could help me!

Is there any way to manage different spine objects from a single script? I have an empty containing two different spine gameobjects and I want both to react to a single script. Is this possible?

Thank you in advance!

    Related Discussions
    ...

    Yimec Hmmm, your question seems more like a Unity question than a spine-unity runtime question. It should be possible to manage multiple SkeletonAnimations from a single script, just like other built-in components. If you want to see a specific example code, please let us know what you actually mean by "manage" that you want to do, such as set or add animations to the AnimationState of these SkeletonAnimations, or set skins to the skeletons.

      Hi Misaki ! Thanks for your reply.

      What I mean is I can reference two Skeleton Animation (each one with its skins and animations), but if I try to reference, for instance:

        [SpineAnimation]
          public string animation;

      The only options I'm given in the Unity inspector are animations from one of the Skeleton Animation. Same for skins (at least, the skins options are labeled with the asset containing them, so I can now they are from the same skeleton animation.

      I hope I'm being clear, if not, don't hesitate to ask me for further information, I'll do my best explaining myself.

      Thank you!

        Yimec I get it now, thanks for the explanation! You can specify the dataField parameter, as in [SpineAnimation(dataField: "skeletonDataAsset")]. For example:

        public SkeletonAnimation skeletonAnimation1;
        
        [SpineAnimation(dataField: "skeletonAnimation1")]
        public string skeleton1_animation;
        
        public SkeletonAnimation skeletonAnimation2;
        
        [SpineAnimation(dataField: "skeletonAnimation2")]
        public string skeleton2_animation;

        The same applies to skins.

          Misaki That worked perfectly! That's the parameter I needed to achieve what I want.

          Thank you very very much!!