Animatables
  • đŸ•šī¸Getting Started
    • Introducing Animatables
    • Installation
    • Components
      • Animation Data
      • Animation Manager
        • Animation Curve Presets
      • Animatable Transform
      • Animatable UI Objects
    • Easing Curves
  • 📄Scripting Basics
    • Animation Registry
    • Creating Animations
      • Animation Creator
      • Animating Numbers
      • Animating Colors
      • Animating Transform
      • Animating Rect Transform
      • Easing Animations
    • Getting Animations
    • Add or Remove Animations
    • Editing Animations
    • Events
  • đŸ› ī¸Support
    • Getting Help
    • Contact
  • 📚Changelogs
    • Latest Releases
Powered by GitBook
On this page
  • Animating a Float
  • Type Conversion
  • Animating a Double
  • Animating an Int
  1. Scripting Basics
  2. Creating Animations

Animating Numbers

Number animation scripting example.

Float, Int, and Double are supported animatable number types. Although, for unsupported types, you can just use implicit or explicit type conversion.

It's required to pass a setter that will set the value of the number that you want animated with each update.

Animating a Float

public class NumberAnimationTest : MonoBehaviour
{
    private float number;

    void Start()
    {
        // Animate number from 0 to 100 in 1 second
        AnimationCreator.FloatAnimation(0, 100, (x) => number = x, 1);
    }

    private void Update()
    {
        Debug.Log(number);
    }
}

Type Conversion

We can use the above example and slightly alter it to animate a numeric type of our choice.

For example, here's how we can animate a ulong instead of a float:

public class NumberAnimationTest : MonoBehaviour
{
    private ulong number;

    void Start()
    {
        // Animate number from 0 to 100 in 1 second
        AnimationCreator.FloatAnimation(0, 100, (x) => number = (ulong)x, 1);
    }

    private void Update()
    {
        Debug.Log(number);
    }
}

Animating a Double

Use AnimationCreator.DoubleAnimation to animate a double.

// Animate number from 0 to 100 in 1 second
AnimationCreator.DoubleAnimation(0, 100, (x) => number = x, 1);

Animating an Int

Use AnimationCreator.IntAnimation to animate an int.

// Animate number from 0 to 100 in 1 second
AnimationCreator.IntAnimation(0, 100, (x) => number = x, 1);
PreviousAnimation CreatorNextAnimating Colors

Last updated 12 months ago

📄