Aesop

  • 30 janv. 2023
  • Inscrit 22 mars 2017
  • Hello!,

    I've tried to find info about this topic and read the API but I don't understand how could and should change an attachment's color. I know the slot color is the way to go, but I use the slot color for another purpose.

    In the current project I'm using a Skeleton Mecanim.

    Thanks for your attention!


    EDIT: I got it working by doing this:

    [SerializeField] private SkeletonMecanim _skelAnim;
    [SerializeField] private Spine.RegionAttachment[] bladeAttachments = new Spine.RegionAttachment[28];
    
    [SerializeField] private Color bootColor;
    
    private void Start()
    {
          bladeAttachments[0] = (Spine.RegionAttachment)_skelAnim.skeleton.GetAttachment("Blade_R_Side_Boot", "Blade_R_Side_Boot_1");
          bladeAttachments[1] = (Spine.RegionAttachment)_skelAnim.skeleton.GetAttachment("Blade_L_Side_Boot", "Blade_L_Side_Boot_1");
    }
    
    void Update()
    {
          if (Input.GetKeyDown(KeyCode.Alpha1))
          {
              bladeAttachments[0].SetColor(bootColor);
              bladeAttachments[1].SetColor(bootColor);
          }
    }

    Even though it works, I still want to know the best practices!
    Thanks for your attention!

  • Asunto: Spine Attachment Color changed at Unity' Runtime

    Aesop a écrit

    Hello!,

    I've tried to find info about this topic and read the API but I don't understand how could and should change an attachment's color. I know the slot color is the way to go, but I use the slot color for another purpose.

    In the current project I'm using a Skeleton Mecanim. And I got it working by doing this:

    [SerializeField] private SkeletonMecanim _skelAnim;
    [SerializeField] private Spine.RegionAttachment[] bladeAttachments = new Spine.RegionAttachment[28];
    
    [SerializeField] private Color bootColor;
    
    private void Start()
    {
          bladeAttachments[0] = (Spine.RegionAttachment)_skelAnim.skeleton.GetAttachment("Blade_R_Side_Boot", "Blade_R_Side_Boot_1");
          bladeAttachments[1] = (Spine.RegionAttachment)_skelAnim.skeleton.GetAttachment("Blade_L_Side_Boot", "Blade_L_Side_Boot_1");
    }
    
    void Update()
    {
          if (Input.GetKeyDown(KeyCode.Alpha1))
          {
              bladeAttachments[0].SetColor(bootColor);
              bladeAttachments[1].SetColor(bootColor);
          }
    }
    

    Even though it works, I still want to know the best practices!

    Thanks for your attention!

  • Awesome! Not only solves my problem, also provides more organization in my Hierarchy!

    THANKS @Harald!

  • Hey! Sorry to bother you!

    I've been searching threads about this but could not find anyone having the same trouble.
    My question: How to add Trail Renderer Component to a specific skeleton attachment/slot in Unity? (basically a trail for a sword slash anim)

    I tried using Skeleton Utility and adding it to the corresponding bone, but I'm pretty sure I'm missing the attachment anyway, because it trails the entire skeleton.
    I'm lost 😢

    Thanks for your attention! 🙂

  • Oh! that's what I was looking for! 🙂 Thanks a lot!

    • Modifié
  • Hey! Sorry to bother you!

    I've been searching threads about this but could not find anyone having the same trouble.
    My question: How could I transition from one slot color to another progressively via c# (I'm using Unity).

    I usually use skeleton.FindSlot().SetColor() but this method does not work with a lerp.
    Is there another way to access slot color? Or how should I approach it?

    Thanks for your attention! 🙂

  • Hi! I'm a begginer coding with Spine, I just never used the internal functions of it to code my animations (always used Mecanim + Skeleton Animator).

    So here's my question (in c#): How do I code in SkeletonGraphic to switch between different animations?

    Example:

    private SkeletonGraphic skeletonGraphic;
    
    [SpineAnimation]
    public string customAnimation;
    
    public void SetAnimation(string animation)
    {
        animation = customAnimation;
        // HERE I WILL CODE THAT THE "CURRENT SKELETONG GRAPHIC ANIMATION" CHANGES TO MY "CUSTOM ANIMATION"
    }

    This Script will be attached to the SkeletonGraphic object, that's why I add a reference to this component.

    Thanks for the support! 🙂

    SOLVED:

    OKAY! I didnt take a look at the API.... ye, I was so lazy....
    In case this could be useful for anyone, there's the quick code solution:

    private SkeletonGraphic skeletonGraphic;
    
    [SpineAnimation]
    public string normalAnim;
    
    void Start()
    {
        skeletonGraphic = GetComponent<SkeletonGraphic>();
    }
    
    public void SetNormal()
    {
        skeletonGraphic.AnimationState.SetAnimation(0, normalAnim, true);
    }

    :sun: :sun: :sun: :sun: :sun:

    • Modifié