Search Results for

    Show / Hide Table of Contents

    Class FadeTransitions

    Utility class for different transitions of various types.

    Inheritance
    System.Object
    FadeTransitions
    Namespace: UniUtils.Data
    Assembly: cs.temp.dll.dll
    Syntax
    public class FadeTransitions : MonoBehaviour

    Methods

    FadeLightColor(Light, Color, Single)

    Coroutine to fade a light's color over time.

    Declaration
    public static IEnumerator FadeLightColor(Light targetLight, Color targetColor, float duration = 1F)
    Parameters
    Type Name Description
    Light targetLight

    The light to modify.

    Color targetColor

    The target color to fade to.

    System.Single duration

    The duration of the fade in seconds.

    Returns
    Type Description
    IEnumerator

    An IEnumerator for use in a coroutine.

    Examples
    // Example: Fade a light's color to blue over 2 seconds.
    StartCoroutine(FadeTransitions.FadeLightColor(
        targetLight: myLight,
        targetColor: Color.blue,
        duration: 2f
    ));

    FadeLightIntensity(Light, Single, Single)

    Coroutine to fade a light's intensity over time.

    Declaration
    public static IEnumerator FadeLightIntensity(Light targetLight, float targetIntensity, float duration = 1F)
    Parameters
    Type Name Description
    Light targetLight

    The light to modify.

    System.Single targetIntensity

    The target intensity to fade to.

    System.Single duration

    The duration of the fade in seconds.

    Returns
    Type Description
    IEnumerator

    An IEnumerator for use in a coroutine.

    Examples
    // Example: Fade a light's intensity to 0 over 1.5 seconds.
    StartCoroutine(FadeTransitions.FadeLightIntensity(
        targetLight: myLight,
        targetIntensity: 0f,
        duration: 1.5f
    ));

    FadeMaterialColor(Material, Color, String, Single)

    Coroutine to fade a material's color property over time.

    Declaration
    public static IEnumerator FadeMaterialColor(Material targetMaterial, Color targetColor, string fieldName = "_EmissionColor", float duration = 1F)
    Parameters
    Type Name Description
    Material targetMaterial

    The material to modify.

    Color targetColor

    The target color to fade to.

    System.String fieldName

    The name of the color property to modify (default is "_EmissionColor").

    System.Single duration

    The duration of the fade in seconds.

    Returns
    Type Description
    IEnumerator

    An IEnumerator for use in a coroutine.

    Examples
    // Example: Fade a material's emission color to red over 3 seconds.
    StartCoroutine(FadeTransitions.FadeMaterialColor(
        targetMaterial: myRenderer.material,
        targetColor: Color.red,
        fieldName: "_EmissionColor",
        duration: 3f
    ));

    FadeValue<T>(Func<T>, Action<T>, T, Func<T, T, Single, T>, Single)

    Generic coroutine to fade a value over time.

    Declaration
    public static IEnumerator FadeValue<T>(Func<T> getter, Action<T> setter, T targetValue, Func<T, T, float, T> lerpFunc, float duration = 1F)
    Parameters
    Type Name Description
    Func<T> getter

    Function to get the current value.

    Action<T> setter

    Action to set the new value.

    T targetValue

    The target value to fade to.

    Func<T, T, System.Single, T> lerpFunc

    Function to interpolate between values.

    System.Single duration

    The duration of the fade in seconds.

    Returns
    Type Description
    IEnumerator

    An IEnumerator for use in a coroutine.

    Type Parameters
    Name Description
    T

    The type of the value to fade.

    Examples
    // Example: Fade a float value from 0 to 1 over 2 seconds.
    StartCoroutine(FadeTransitions.FadeValue(
        getter: () => someValue,
        setter: val => someValue = val,
        targetValue: 1f,
        lerpFunc: Mathf.Lerp,
        duration: 2f
    ));
    In This Article
    Back to top UniUtils Documentation