static void Add( System.Object owningObject, float secondsToTake, float from, float to, System.Action<float> value, string ease )

robot_2Generated
code_blocksInput

Description

The Add method in the Editor.Animate class is used to create an animation that interpolates a value over a specified duration. This method is static and can be called without instantiating the Animate class. It allows you to animate a property from a starting value to an ending value using a specified easing function.

Usage

To use the Add method, you need to provide the following parameters:

  • owningObject: The object that owns the animation. This is typically the object whose property you are animating.
  • secondsToTake: The duration of the animation in seconds.
  • from: The starting value of the property you want to animate.
  • to: The ending value of the property you want to animate.
  • value: An Action<float> delegate that is called with the interpolated value on each frame of the animation.
  • ease: A string representing the easing function to use for the animation. Common easing functions include "linear", "easeIn", "easeOut", etc.

Example

// Example usage of the Editor.Animate.Add method

// Assume we have a GameObject with a property 'Opacity' that we want to animate
GameObject myObject = new GameObject();

// Define the animation
Editor.Animate.Add(
    owningObject: myObject,
    secondsToTake: 2.0f, // Duration of 2 seconds
    from: 0.0f,          // Start from 0
    to: 1.0f,            // End at 1
    value: (float v) => {
        // Update the Opacity property of the object
        myObject.Opacity = v;
    },
    ease: "easeInOut"    // Use an ease-in-out easing function
);