Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Additive animations for UI elements

Discussion in 'UGUI & TextMesh Pro' started by aleiby, Oct 14, 2014.

  1. aleiby

    aleiby

    Joined:
    Mar 14, 2012
    Posts:
    13
    I love how easy it is to create an animation on any property of a UI element. I have a button that I want to slide, but retain its scaling relative to the screen, so I animated Anchor.Min.X and Anchor.Max.X. However, I have multiple instances of this button as a prefab, and I'd like to be able to apply the animation to each of them regardless of where they might currently be on the screen. I want the animated values to add to the button's current values rather than replace them.

    Is there any way to make these play back additively?

    For reference, when you animate a property on a GUI element, it adds an Animator component to your widget which references a new Animation Controller asset. That anim controller has a State for each new animation you add, and each State's Motion property points to a separate .anim asset where the data is stored.

    I was hoping there was a BlendMode.Additive I could set on the animation asset, or some interface for playing in script using additive blending.
     
  2. rakkarage

    rakkarage

    Joined:
    Feb 3, 2014
    Posts:
    683
    i think that would be a great feature for the animator

    one way to workaround it for now is to use a tween system that provides different methods for (moveTo and moveBy | move and moveLocal) like iTween or LeanTween or DOTween
     
  3. aleiby

    aleiby

    Joined:
    Mar 14, 2012
    Posts:
    13
    That's what I figured. I was actually looking int DOTween last night after posting this as an alternative. Part of my goal of this project was to exercise the new 4.6 UI system while trying to avoid using any third party add-ons (since its whole point is to replace nGUI, et al). Thanks!